public static class RandomUtils.MersenneTwisterRNG extends RandomBase
Random number generator based on the Mersenne Twister algorithm developed by Makoto Matsumoto and Takuji Nishimura.
This is a very fast random number generator with good statistical properties
(it passes the full DIEHARD suite). This is the best RNG for most
experiments. If a non-linear generator is required, use the slower
AESCounterRNG
RNG.
This PRNG is deterministic, which can be advantageous for testing purposes since the output is repeatable. If multiple instances of this class are created with the same seed they will all have identical output.
This code is translated from the original C version and assumes that we will always seed from an array of bytes. I don't pretend to know the meanings of the magic numbers or how it works, it just does.
NOTE: Because instances of this class require 128-bit seeds, it is not
possible to seed this RNG using the Random.setSeed(long)
method inherited
from Random
. Calls to this method will have no effect.
Instead the seed must be set by a constructor.
Modifier and Type | Field and Description |
---|---|
static int[] |
SEEDS |
Constructor and Description |
---|
MersenneTwisterRNG(int... seedInts)
Creates an RNG and seeds it with the specified seed data.
|
Modifier and Type | Method and Description |
---|---|
protected int |
next(int bits) |
doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, nextLong