Mt19937

Mersenne Twister generators with well-chosen parameters. Mt11213b offers a generator with a period of 2^11213 - 1 and a 32-bit datatype, while Mt19937 and Mt19937_64 offer generators with 32- and 64-bit datatypes respectively, both having a period of 2^19937 - 1. The three generators offer a good uniform distribution in up to 350, 623 and 311 dimensions respectively. Mt19937 is the most typical configuration, widely used in many different programming languages as a high-quality default random number generator.

alias Mt19937 = MersenneTwisterEngine!(uint, 32, 624, 397, 31, 0x9908b0dfU, 11, 0xffffffffU, 7, 0x9d2c5680U, 15, 0xefc60000U, 18, 1812433253U)

Examples

// Initialize a Mersenne Twister seeded with constant default value
auto rng = new Mt19937;
auto n = rng.front;  // same for each run
// Seed with a thread-safe unpredictable value
rng.seed(unpredictableSeed);
n = rng.front;  // different across runs

For extensive information on the Mersenne Twister generator and the choices of parameters, see the Mersenne Twister homepage hosted by the Department of Mathematics at Hiroshima University.

Meta