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