MersenneTwister 1.0 review
DownloadMersenneTwister is a C++ class for generating random numbers
|
|
MersenneTwister is a C++ class for generating random numbers. It was designed with consideration of the flaws in various other generators.
The period, 2^19937-1, and the order of equidistribution, 623 dimensions, are far greater. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. See the inventors' page for more details.
I have implemented the Mersenne Twister in a C++ class that is fast, convenient, portable, and free. Take a look at the class or download the complete package in zip or tarball format.
Here are some key features of "MersenneTwister":
Simple creation of generator with MTRand r;
Convenient access with double a = r();
Generation of integers or floating-point numbers
Easy seeding options
Automatically from /dev/urandom or time() and clock()
Single integer
Arrays of any length (to access full 19937-bit range)
Ability to save and restore state
Thorough example program
Validation and performance tests
Open source code under BSD license
On my system, a Pentium III running Linux at 500 MHz, the performance test gives the following results for generation of random integers:
MersenneTwister.h 28.4 million per second
Inventors' C version 14.3 million per second
Cokus's optimized C version 16.6 million per second
Standard rand() 6.8 million per second
MersenneTwister 1.0 search tags