#include <Random.h>
Public Methods | |
| std::string | getName () const |
| Get the name of this generator. | |
| MT19937 () | |
| 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(). | |
Original implementation was copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. Coded by Takuji Nishimura, considering the suggestions by Topher Cooper and Marc Rieffel in July-Aug. 1997, "A C-program for MT19937: Integer version (1998/4/6)"
This class was adapted from the c-implementation of Matsumoto's algorithm that is part of the GNU Scientific Library. That implementation is copyright (C) 1998 Brian Gough.
Brian Gough's notes follow:
I reorganized the code to use the module framework of GSL. The license on this implementation was changed from LGPL to GPL, following paragraph 3 of the LGPL, version 2.
Update:
The seeding procedure has been updated to match the 10/99 release of MT19937.
Update:
The seeding procedure has been updated again to match the 2002 release of MT19937
The original code included the comment: "When you use this, send an email to: matumoto@math.keio.ac.jp with an appropriate reference to your work".
Makoto Matsumoto has a web page with more information about the generator, http://www.math.keio.ac.jp/~matumoto/emt.html.
The paper below has details of the algorithm.
From: Makoto Matsumoto and Takuji Nishimura, "Mersenne Twister: A 623-dimensionally equidistributerd uniform pseudorandom number generator". ACM Transactions on Modeling and Computer Simulation, Vol. 8, No. 1 (Jan. 1998), Pages 3-30
You can obtain the paper directly from Makoto Matsumoto's web page.
The period of this generator is 2^{19937} - 1.
|
|
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. |