swarm-support
[Top][All Lists]
Advanced

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

Re: Random Seed question


From: Theodore C. Belding
Subject: Re: Random Seed question
Date: Sun, 30 Jan 2000 15:56:36 -0500 (EST)

On Sat, 29 Jan 2000, Rick Riolo wrote:

> If I recall correctly (ted could tell us for sure),
> Drone uses what might be viewed as a more compressed
> way of "storing" a stream of RNG seeds:  it starts
> with a number created from the clock and task number,
> and uses that as a seed for one kind of RNG, which
> then creates a sequence of numbers to use as seeds
> for some other kind of RNG.   

Right: timestamp * process ID. Note that if you use this number as a seed,
you may have to convert it so that it's within the legal range of seeds
for your RNG.

> It is important, of course,
> to use different kinds of RNGs for the seed generator
> vs what is used in your simulation.

Stated more generally, it's important that the algorithm you use for
generating seeds is uncorrelated with the RNG that you plug the seeds
into. In retrospect, I don't think it's absolutely necessary to use an RNG
to generate the seeds. Simply adding 1 to the last seed each time should
be sufficient, as long as the sequence of seeds that you produce that way
is unlikely to be produced again if you run another N runs of your
simulation.

This is because, as Doug Donalson said, it shouldn't matter what seed you
give to the RNG as long as it's within the legal range and as long as it's
unlikely that you use the same seed twice.  (For instance some RNGs can't
be given a seed of 0, or negative seeds, or they have a maximum legal
seed value.) 

Knuth [1] explicitly says you can use any legal value for a seed,
including the date:
"The 'seed' number X0 may be chosen arbitrarily. If the program is run
several times and a different source of random numbers is desired each
time, set X0 to the last value attained by [the RNG] X on the preceding
run; or (if more convenient) set X0 to the current date and time."

Note that Knuth is assuming that you're only running one simulation at a
time. If there's a chance that more than one simulation will start at the
same time and date, then you should not just use the time and date as the
seed; you should modify it somehow, for instance by multiplying it with
the process ID number.
-Ted

[1] Knuth, D. E. (1998). The Art of Computer Programming. Vol. 2:
Seminumerical Algorithms. 3rd edition. Addison-Wesley, http://www.awl.com/
ISBN 0-201-89684-2. Section 3.6, p. 184.

--
Ted Belding                              address@hidden 
University of Michigan Center for the Study of Complex Systems
Homepage: http://www-personal.umich.edu/~streak/
PGP key:  http://www-personal.umich.edu/~streak/pgp-key.html


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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