[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: generating random numbers -- what seeds to use?
From: |
Dirk Eddelbuettel |
Subject: |
Re: generating random numbers -- what seeds to use? |
Date: |
Sun, 27 Apr 2003 20:59:39 -0500 |
User-agent: |
Mutt/1.3.28i |
On Sun, Apr 27, 2003 at 08:03:41PM -0500, John W. Eaton wrote:
> 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);
> endfor
>
> Then you could read these files for your data generation processes.
Yep. And some more ideas:
- use a generator with more states than the n=10 you need here; one well known
and tested example is ranlib from U Texas which has 32 virtual states that
are all shielded; ranlib comes in C and Fortran flavour; see
http://lib.stat.cmu.edu/general/Utexas/randlib.readme
- use an external random number, either for the entire sequence or for the
initialisation; http://random.org is a popular choice
Hth, Dirk
--
Don't drink and derive. Alcohol and algebra don't mix.
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------