Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

rng::MT19937 Class Reference

Mersenne Twister random number generator. More...

#include <Random.h>

List of all members.

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().


Detailed Description

Mersenne Twister random number generator.

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.


Constructor & Destructor Documentation

rng::MT19937::MT19937   [inline]
 

Construct a new generator with seed 0.


Member Function Documentation

std::string rng::MT19937::getName   const [inline]
 

Get the name of this generator.

void rng::MT19937::getState State   state const
 

Save the current state of the generator.

The state can be restored at any time with setState().

void rng::MT19937::setSeed unsigned long int    s
 

Reseed the random number generator.

Parameters:
s  the new seed.

void rng::MT19937::setState State const &    state
 

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.

double rng::MT19937::uniform double    lower,
double    upper
[inline]
 

Return a random floating point value in the range [lower, upper).

template<typename T>
T rng::MT19937::uniformInt   upper [inline]
 

Equivalent to uniformInt(0, upper).

template<typename T>
T rng::MT19937::uniformInt   lower,
  upper
[inline]
 

Return a random integer in the range lower to upper-1 (inclusive).

Parameters:
lower  lower bound (inclusive)
upper  upper bound (exclusive)
Returns:
a random integer int the range lower to upper-1 (inclusive)

double rng::MT19937::unit   [inline]
 

Return a random floating point value in the range [0, 1).


The documentation for this class was generated from the following files:
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.

[SF.net]