Inheritance diagram for MTRand:
This class is the base for all of the (pseudo) random number generators. It is based closely on MersenneTwister.h, v0.6, 14 February 2001, written by Richard J. Wagner. It has been modified and substantially trimmed down.
Definition at line 52 of file Random.H.
Public Member Functions | |
MTRand (const unsigned long &oneSeed) | |
void | setSeed (unsigned long seed) |
Set the random number seed. | |
void | randomize () |
Set the random number seed using a number generated from /dev/urandom . | |
Moments of the random variable | |
virtual double | mean () const=0 |
virtual double | variance () const=0 |
virtual double | stdDev () const=0 |
Protected Member Functions | |
double | rand () |
uint32 | randInt () |
uint32 | randInt (const uint32 &n) |
Private Types | |
enum | { N = 624, M = 397, MAGIC = 0x9908b0dfU } |
typedef unsigned long | uint32 |
Private Member Functions | |
void | reload () |
uint32 | hiBit (const uint32 &u) const |
uint32 | loBit (const uint32 &u) const |
uint32 | loBits (const uint32 &u) const |
uint32 | mixBits (const uint32 &u, const uint32 &v) const |
uint32 | twist (const uint32 &m, const uint32 &s0, const uint32 &s1) const |
MTRand (const MTRand &mtrand) | |
MTRand & | operator= (const MTRand &mtrand) |
Private Attributes | |
uint32 | state [N] |
uint32 * | pNext |
int | left |
MTRand | ( | const unsigned long & | oneSeed | ) | [inline] |
void setSeed | ( | unsigned long | seed | ) | [inline] |
void randomize | ( | ) | [inline] |
virtual double mean | ( | ) | const [pure virtual] |
Implemented in RealRandom, IntegerRandom, UniformRandomSimple, UniformRandom, NormalRandom, ExponentialRandom, DiscreteUniformRandom, and BernoulliRandom.
virtual double variance | ( | ) | const [pure virtual] |
Implemented in RealRandom, IntegerRandom, UniformRandomSimple, UniformRandom, NormalRandom, ExponentialRandom, DiscreteUniformRandom, and BernoulliRandom.
virtual double stdDev | ( | ) | const [pure virtual] |
Implemented in RealRandom, IntegerRandom, UniformRandomSimple, UniformRandom, NormalRandom, ExponentialRandom, DiscreteUniformRandom, and BernoulliRandom.
double rand | ( | ) | [inline, protected] |
Basic double precision random number.
Definition at line 82 of file Random.H.
References randInt().
Referenced by NormalRandom::number(), BernoulliRandom::number(), UniformRandom::number(), and UniformRandomSimple::number().
MTRand::uint32 randInt | ( | ) | [inline, protected] |
MTRand::uint32 randInt | ( | const uint32 & | n | ) | [inline, protected] |
void reload | ( | ) | [inline, private] |