• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1This is a Mersenne Twister pseudorandom number generator
2with period 2^19937-1 with improved initialization scheme,
3modified on 2002/1/26 by Takuji Nishimura and Makoto Matsumoto.
4
5Contents of this tar ball:
6readme-mt.txt	 this file
7mt19937ar.c	 the C source (ar: initialize by ARray)
8mt19937ar.out	 Test outputs of six types generators. 1000 for each
9
101. Initialization
11  The initialization scheme for the previous versions of MT
12(e.g. 1999/10/28 version or earlier) has a tiny problem, that
13the most significant bits of the seed is not well reflected
14to the state vector of MT.
15
16This version (2002/1/26) has two initialization schemes:
17init_genrand(seed) and init_by_array(init_key, key_length).
18
19init_genrand(seed) initializes the state vector by using
20one unsigned 32-bit integer "seed", which may be zero.
21
22init_by_array(init_key, key_length) initializes the state vector
23by using an array init_key[] of unsigned 32-bit integers
24of length key_kength. If key_length is smaller than 624,
25then each array of 32-bit integers gives distinct initial
26state vector. This is useful if you want a larger seed space
27than 32-bit word.
28
292. Generation
30After initialization, the following type of pseudorandom numbers
31are available.
32
33genrand_int32() generates unsigned 32-bit integers.
34genrand_int31() generates unsigned 31-bit integers.
35genrand_real1() generates uniform real in [0,1] (32-bit resolution).
36genrand_real2() generates uniform real in [0,1) (32-bit resolution).
37genrand_real3() generates uniform real in (0,1) (32-bit resolution).
38genrand_res53() generates uniform real in [0,1) with 53-bit resolution.
39
40Note: the last five functions call the first one.
41if you need more speed for these five functions, you may
42suppress the function call by copying genrand_int32() and
43replacing the last return(), following to these five functions.
44
453. main()
46main() is an example to initialize with an array of length 4,
47then 1000 outputs of unsigned 32-bit integers,
48then 1000 outputs of real [0,1) numbers.
49
504. The outputs
51The output of the mt19937ar.c is in the file mt19937ar.out.
52If you revise or translate the code, check the output
53by using this file.
54
555. Cryptography
56This generator is not cryptoraphically secure.
57You need to use a one-way (or hash) function to obtain
58a secure random sequence.
59
606. Correspondence
61See:
62URL http://www.math.keio.ac.jp/matumoto/emt.html
63email matumoto@math.keio.ac.jp, nisimura@sci.kj.yamagata-u.ac.jp
64
657. Reference
66M. Matsumoto and T. Nishimura,
67"Mersenne Twister: A 623-Dimensionally Equidistributed Uniform
68Pseudo-Random Number Generator",
69ACM Transactions on Modeling and Computer Simulation,
70Vol. 8, No. 1, January 1998, pp 3--30.
71
72-------
73Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
74All rights reserved.
75