Mersenne Twister random number generator. More...
#include <sqlrand.h>
Static Public Member Functions | |
static void | deinit () |
Deinitialize the class. More... | |
static void | init () |
Initialize the class. More... | |
static double | nextDouble () |
Returns random double number. More... | |
static unsigned long | random () |
Returns random integer number. More... | |
static double | gaussian () |
Returns variate of the normal distribution. More... | |
Mersenne Twister random number generator.
This code is based on code written by Michael L. Brundage which he has placed in the public domain (see http://www.qbrundage.com/michaelb/pubs/essays/random_number_generation.html ).
Matsumoto, Makoto and Nishimura, Takuji,
"Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random
number generator",
ACM Transactions on Modeling and Computer Simulation, 1998
|
static |
Deinitialize the class.
void MersenneTwister::deinit() This method must be called before leaving the program to release all resources and memory associated to the class.
Definition at line 45 of file sqlrand.cc.
|
static |
Returns variate of the normal distribution.
A random number is created according to a normal distribution with mean = 0 and standard deviation = 1 using the Marsaglia polar method. The Maraglia method avoids the calculation of sine and cosine found in the Box-Muller transform.
Definition at line 111 of file sqlrand.cc.
|
static |
Initialize the class.
This method must be called be called before using the class.
It creates mutexes and initializes the buffer.
Definition at line 51 of file sqlrand.cc.
|
static |
Returns random double number.
A double random number in the range [0,1[ is generated. It has 53 random bits.
Definition at line 104 of file sqlrand.cc.
|
static |
Returns random integer number.
A random number is retrieved from the buffer. If the buffer is empty new random numbers are generated.
Definition at line 69 of file sqlrand.cc.