Article View: sci.math.stat
Article #216Re: Seeding random number generators
From: Graham Wills
Date: Thu, 16 Apr 1992 08:44
Date: Thu, 16 Apr 1992 08:44
41 lines
2524 bytes
2524 bytes
In article <2532@creatures.cs.vt.edu> lavinus@csgrad.cs.vt.edu (Joseph Lavinus) writes: >Is there a statistically acceptable way to seed a random number generator >in a computer program? I'm using the following RNG (the multiplicative >congruential "minimal standard" published in Communications of the ACM >a while back): > > Z(i) = 7**5 Z(i-1) mod (2**31 - 1) > Z(0) = seed > >I've been using the program's process id as a seed, but > (a) I'm not at all sure that's a good idea, and > (b) Suddenly I need several RNGs simultaneously. > >So, the question is, is there a statistically "good" way to seed a number >(say 10, for concreteness' sake) of RNGs, such that they do not act the same >each time the program is run, and such that each stream is statistically >independent of the others, without requiring any intervention from the user? As regards (a), the process id may be a perfectly reasonable seed, but one of the traditional seeds programmers use is some sort of system call which returns a time. On the Macintosh I use a call which gives me the number of seconds since midnight, Jan 1, 1900. Other systems allows the number of milliseconds since last boot. They're a good bet. Essentially, the problem is that a good way to seed is with a random number, which is why you wanted a random number generator in the first place ... For (b), why do you feel the need for a number of RNGs? Since each result taken from the stream is independent of the others (for a good RNG), just use one *good* RNG and take all your values from it. If you use several RNGs all of the same type, you may end up with highly dependent series (Imagine the disaster if they got seeded with values close to each other on the cycle; you'd get a perfect lag relationship) >Also, I'm certainly open to arguments about why I should use a RNG other >than the one described above... A reasonable refernce to examine is "Stochastic Simulation"; B.D. Ripley It discusses a number of generators and is fairly application-oriented. -Graham Wills Trinity College Dublin, Ireland
Technical Details
Message-ID:
<1992Apr16.084437.18471@maths.tcd.ie>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!ieunet!tcdcs!maths.tcd.ie!gwillsReferences:
<2399@news.duke.edu> <2532@creatures.cs.vt.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!ieunet!tcdcs!maths.tcd.ie!gwills From: gwills@maths.tcd.ie (Graham Wills) Newsgroups: sci.math.stat Subject: Re: Seeding random number generators Message-ID: <1992Apr16.084437.18471@maths.tcd.ie> Date: 16 Apr 92 08:44:37 GMT References: <2399@news.duke.edu> <2532@creatures.cs.vt.edu> Organization: Dept. of Maths, Trinity College, Dublin, Ireland. Lines: 41