Mersenne Twister:
A Study on Random Number Generators
The Mersenne Twister[1]
(MT) is a new algorithm for generating pseudo random numbers. It has the
following advantages in comparison to the other generators:
The algorithm itself is an improved variant of Twisted Generalized Feedback Register (TGSFR[2]). The 'twist' is a transformation, which assures equidistribution of the generated numbers in 623 dimensions (linear congruential generators can at best manage reasonable distribution in 5 dimensions).
Here we present a study on Mersenne Twister and it's predecessors Twisted GFSR, GFSR and Tausworthe generators also some popular generators like the Linear Congruential Generators, their theory and background and implementations. The study also focuses on testing, measuring and comparing random number generators and gives an didactic introduction to k-distribution property and spectral test.
The project contains a random number generator library which includes popular instances of above mentioned generators and 3 applications to demonstrate the certain aspects discussed in the study.
There's a paper discussing the theory and a report which gives information about the design and the implementation.
Following are the 2 dimensional distributivity of some random number generators as plotted by the application. The density of the dots gives a measure of randomness for the numbers generated by these generators.

The left most plot belongs to LCG-276 instance. The pairs of random numbers only appear with certain combinations. As the k-distributivity increases pairs have almost all of the combinations in the given interval. In MT the plotted plots fill in every possible cross section on the graph after a while meaning the generated numbers have equal possibility to appear.
Following are the comparisons between different RNG instances using the Cesaro's Method for calculating the Pi with 15000 Monte-Carlo experiments. As the randomness of the generated sequences increase the accuracy of the estimation increases.
| Generator |
Estimated Pi |
Error |
Accuracy(%) |
| MT19937 | 3.14174882107861 | -0.000156167 | 99.99502903 |
| MT11213A | 3.14312799095236 | -0.001535337 | 99.95112869 |
| MT11213B | 3.14641081249572 | -0.004818159 | 99.84663324 |
| TT800 | 3.15771979876276 | -0.016127145 | 99.48665703 |
| T400 | 3.13436676124481 | 0.007225892 | 99.76999270 |
| T403 | 3.15929528896189 | -0.017702635 | 99.43650761 |
| T775 | 3.13009871443637 | 0.011493939 | 99.63413655 |
| T800 | 3.13402467483056 | 0.007567979 | 99.75910375 |
| TAUSWORTHE7-3 | 3.23104072607105 | -0.089448072 | 97.15277942 |
| RANDOM-SCHEME | 3.14416356112738 | -0.002570908 | 99.91816547 |
| RAND-ANSI | 3.14347306730965 | -0.001880414 | 99.94014457 |
| RANDU | 2.72479676423189 | 0.416795889 | 86.73297479 |
| LM | 3.15057227466379 | -0.008979621 | 99.71416978 |
| MINSTD1 | 3.13060995963610 | 0.010982694 | 99.65040999 |
| MINSTD2 | 3.14019942295212 | 0.001393231 | 99.95565209 |
| SUPER-DUPER | 2.71774363918035 | 0.423849014 | 86.50846685 |
| BCPL | 2.72817475234362 | 0.413417901 | 86.84049949 |
| LCG-SICP | 3.38448721711206 | -0.242894564 | 92.26842591 |
| LCG-276 | 3.58568582800318 | -0.444093174 | 85.86407522 |
| LCG-277 | 3.16227766016837 | -0.020685007 | 99.34157579 |
Mersenne Twister has the most accurate Pi value, leaving the instance with ANSI-C rand and PLT Scheme's internal generator. It is interesting to see that for this test instance the trivial LCG-277 (cycle length is only 31) scores better than some of the sophisticated generators with longer cycle lengths including IBM's famous RANDU. However this test is quite subjective as certain sequence of numbers may just have good combinations for calculating the Pi (maybe sequence 1,2,3,... gives an accurate estimation as well) . Therefore this test alone is not enough to give a conclusion about the randomness of the generator.
Mersenne Twister and Random Number Generators Theory and Background
Mersenne Twister and Random Number Generators Design and Implementation
Random Number Generator Library and Demo Applications Sources
[2]Twisted
GFSR Generators, Makoto Matsumoto, Yoshiharu Kurita, Research Institute of
Mathematical Sciences, Kyoto University, 1992