#include <Random.h>
Public Methods | |
| std::string | getName () const |
| Get the name of this generator. | |
| Taus2 () | |
| Construct a new generator with seed 0. | |
| template<typename T> T | uniformInt (T lower, T upper) |
| Return a random integer in the range lower to upper-1 (inclusive). | |
| template<typename T> T | uniformInt (T upper) |
| Equivalent to uniformInt(0, upper). | |
| double | unit () |
| Return a random floating point value in the range [0, 1). | |
| double | uniform (double lower, double upper) |
| Return a random floating point value in the range [lower, upper). | |
| void | setSeed (unsigned long int s) |
| Reseed the random number generator. | |
| void | getState (State &state) const |
| Save the current state of the generator. | |
| void | setState (State const &state) |
| Restore the generator to a specific state saved with getState(). | |
This class was adapted from the c-implementation of the taus2 random number generator included in the GNU Scientific Library (rng/taus.c). That implementation is copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough.
Comments from the GSL implementation follow:
This is a maximally equidistributed combined Tausworthe generator. The sequence is,
x_n = (s1_n ^ s2_n ^ s3_n)
s1_{n+1} = (((s1_n & 4294967294) <<12) ^ (((s1_n <<13) ^ s1_n) >>19)) s2_{n+1} = (((s2_n & 4294967288) << 4) ^ (((s2_n << 2) ^ s2_n) >>25)) s3_{n+1} = (((s3_n & 4294967280) <<17) ^ (((s3_n << 3) ^ s3_n) >>11))
computed modulo 2^32. In the three formulas above '^' means exclusive-or (C-notation), not exponentiation. Note that the algorithm relies on the properties of 32-bit unsigned integers (it is formally defined on bit-vectors of length 32). I have added a bitmask to make it work on 64 bit machines.
We initialize the generator with s1_1 .. s3_1 = s_n MOD m, where s_n = (69069 * s_{n-1}) mod 2^32, and s_0 = s is the user-supplied seed.
The theoretical value of x_{10007} is 2733957125. The subscript 10007 means (1) seed the generator with s=1 (2) do six warm-up iterations, (3) then do 10000 actual iterations.
The period of this generator is about 2^88.
From: P. L'Ecuyer, "Maximally Equidistributed Combined Tausworthe Generators", Mathematics of Computation, 65, 213 (1996), 203--213.
This is available on the net from L'Ecuyer's home page,
http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme.ps ftp://ftp.iro.umontreal.ca/pub/simulation/lecuyer/papers/tausme.ps
Update: April 2002
There is an erratum in the paper "Tables of Maximally Equidistributed Combined LFSR Generators", Mathematics of Computation, 68, 225 (1999), 261--269: http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme2.ps
... the k_j most significant bits of z_j must be non- zero, for each j. (Note: this restriction also applies to the computer code given in [4], but was mistakenly not mentioned in that paper.)
This affects the seeding procedure by imposing the requirement s1 > 1, s2 > 7, s3 > 15.
The generator taus2 has been added to satisfy this requirement. The original taus generator is unchanged.
Update: November 2002
There was a bug in the correction to the seeding procedure for s2. It affected the following seeds 254679140 1264751179 1519430319 2274823218 2529502358 3284895257 3539574397 (s2 < 8).
|
|
Construct a new generator with seed 0.
|
|
|
Get the name of this generator.
|
|
|
Save the current state of the generator. The state can be restored at any time with setState(). |
|
|
Reseed the random number generator.
|
|
|
Restore the generator to a specific state saved with getState(). The subsequent random numbers will be identical to the sequence following the corresponding getState() call. |
|
||||||||||||
|
Return a random floating point value in the range [lower, upper).
|
|
||||||||||
|
Equivalent to uniformInt(0, upper).
|
|
||||||||||||||||
|
Return a random integer in the range lower to upper-1 (inclusive).
|
|
|
Return a random floating point value in the range [0, 1).
|
|
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage. Generated on Tue Oct 14 12:06:43 2003, using Doxygen 1.2.18. |