Mersenne Twister


URI:

http://herbert.gandraxa.com/herbert/rng.asp

Link template:   

<a href="http://herbert.gandraxa.com/herbert/rng.asp">Mersenne Twister</a>


Link symbols:   

Local LinkOn current page | DocumentOn this site | External PageOn external site | WikipediaWikipedia article | Compressed ArchiveZIP archive | PDF documentPDF | E-MailE-Mail


Article

Organization

DocumentHome » DocumentLinoleum Source Code » Mersenne Twister

Download as a WinZip file see below.

Scope

This implements the Mersenne Twister 19937 in the WikipediaLinoleum Programming Language.

The Mersenne Twister 19939 (commonly referred to as "MT19937") is a pseudorandom number generator developed in 1997 by Makoto Matsumoto and Takuji Nishimura.

It provides for fast generation of very high quality pseudorandom numbers, having been designed specifically to rectify many of the flaws found in older algorithms.

There are at least two common variants of the algorithm, differing only in the size of the Mersenne primes used. The newer and more commonly used one is MT19937, which is the one implemented here.

Algorithm Development Update: In August 2006 a new version was released, named "SIMD-oriented Fast Mersenne Twister (SFMT)" (commonly referred to as SFMT19937). Quote from the developers' External Siteannoucement:

SFMT is a Linear Feedbacked Shift Register (LFSR) generator that generates a 128-bit pseudorandom integer at one step. SFMT is designed with recent parallelism of modern CPUs, such as multi-stage pipelining and SIMD (e.g. 128-bit integer) instructions.

For details see the External Pages section.

Author

DocumentHerbert Glarner

Published

2006-May-30

External Pages


Download

The following ZIP file contains both the library's source (RNG.txt) as well as a test program (RNG Test.txt).

Zipped ArchiveRNG.zip

Note: For naming convention reasons my libraries all begin with a 3-characters prefix; RNG (Random Number Generator) was the natural choice for this library. Despite its naming, though, this is a Pseudo Random Number Generator. Thanks to Paul E. Black (External PageNIST) to pointing out this potentially irritating naming of mine.


Test

The implementation was tested with the first External Page1,000 output numbers provided by the developers of the algorithm.


Speed

PRNs = Pseudo Random Numbers

Machine Measured Interpolated per second
Intel Pentium 4, 1.328 GHz 500 million PRNs in 17 seconds 29.4 million PRNs/second
Intel Celeron D 346, 3.066 GHz 2 billion PRNs in 28 seconds 71.4 million PRNs/second

Note: There is plenty of room for speed optimization. The current implementation focusses on correctness.