#include
#include
/*
Makoto Matsumoto and Takuji Nishimura, "Mersenne Twister:
A 623-dimensionally equidistributed uniform pseudorandom
number generator". ACM Transactions on Modeling and Computer
Simulation, Vol. 8, No. 1 (Jan. 1998), Pages 3-30
*/
/* See documentation for the GNU Scientific Library
http://www.gnu.org/software/gsl/manual/gsl-ref_17.html#SEC260
*/
/*
Generator: gsl_rng_mt19937 The MT19937 generator of Makoto Matsumoto
and Takuji Nishimura is a variant of the twisted generalized
feedback shift-register algorithm, and is known as the "Mersenne
Twister" generator. It has a Mersenne prime period of 2^19937 - 1
(about 10^6000) and is equi-distributed in 623 dimensions. It has
passed the DIEHARD statistical tests. It uses 624 words of state
per generator and is comparable in speed to the other
generators. The original generator used a default seed of 4357 and
choosing s equal to zero in gsl_rng_set reproduces this.
For more information see,
* Makoto Matsumoto and Takuji Nishimura, "Mersenne Twister: A
* 623-dimensionally equidistributed uniform pseudorandom
* number generator". ACM Transactions on Modeling and Computer
* Simulation, Vol. 8, No. 1 (Jan. 1998), Pages 3-30
The generator gsl_rng_19937 uses the second revision of the
seeding procedure published by the two authors above in 2002. The
original seeding procedures could cause spurious artifacts for
some seed values. They are still available through the alternate
generators gsl_rng_mt19937_1999 and gsl_rng_mt19937_1998.
*/
#define GSL_RNG_TYPE mrg
#define GSL_RNG_SEED 4444
int
main (void)
{
gsl_rng * r = gsl_rng_alloc (gsl_rng_mt19937);
int i, n = 500000;
gsl_rng_set(r, 4444);
for (i = 0; i < n; i++)
{
double u = gsl_rng_uniform (r);
printf ("%f\n", u);
}
gsl_rng_free (r);
return 0;
}
/*
Local Variables:
compile-command: "gcc -Wall -o mtdemo main-MTDemo.c -lgsl -lgslcblas -lm"
End:
*/