[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

generating random numbers -- what seeds to use?

From: John W. Eaton
Subject: generating random numbers -- what seeds to use?
Date: Sun, 27 Apr 2003 20:03:41 -0500

On 27-Apr-2003, Mike Miller <address@hidden> wrote:

| I need to create large amounts of random data under a certain model.  I
| wanted to produce 10,000 files, so I set 10 different processors to the
| task of executing an octave scrit that would make 1,000 files.
| Unfortunately, I forgot that some of the jobs were starting at nearly the
| same moment, so they took the same seed from the clock and produced the
| same 'random' files!
| I'd still like to run 10 jobs at once, but I'll have to supply initial
| seeds.  Is there any way that I can guarantee that I won't produce the
| same file twice?  What is the best way to choose seeds?  What is the
| period for Octave's random number generator?  Has anyone developed other
| random number generators for Octave?

Why not generate all the random numbers in advance?  For example, for
N random numbers in each of M files, something like

  for i = 1:M
    f = fopen (sprintf ("rnd-%d", i), "w");
    fwrite (f, rand (N, 1), "double");
    fclose (f);

Then you could read these files for your data generation processes.


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]