Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
Static Public Member Functions | List of all members
sqlstat::MersenneTwister Class Reference

Mersenne Twister random number generator. More...

#include <sqlrand.h>

Collaboration diagram for sqlstat::MersenneTwister:
Collaboration graph

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

Detailed Description

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

Definition at line 60 of file sqlrand.h.

Member Function Documentation

void sqlstat::MersenneTwister::deinit ( )
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.

double sqlstat::MersenneTwister::gaussian ( )
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.

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlstat::MersenneTwister::init ( )
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.

Here is the caller graph for this function:

double sqlstat::MersenneTwister::nextDouble ( )
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.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long sqlstat::MersenneTwister::random ( )
static

Returns random integer number.

A random number is retrieved from the buffer. If the buffer is empty new random numbers are generated.

Returns
Random number

Definition at line 69 of file sqlrand.cc.

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: