public class MersenneTwisterRandomGenerator extends java.lang.Object implements UniformRandomGenerator
desmoj.dist.UniformRandomGenerator
interface. The algorithm for
pseudo random number generation is based on the Mersenne twister variant
MT19937 and has a period of 219937 - 1; see the Mersenne twister
wikipedia entry for details.UniformRandomGenerator
,
Distribution
,
Random
Constructor and Description |
---|
MersenneTwisterRandomGenerator()
Creates a MersenneTwisterRandomGenerator with seed 42.
|
MersenneTwisterRandomGenerator(long seed)
Creates a MersenneTwisterRandomGenerator with given value as initial
seed.
|
Modifier and Type | Method and Description |
---|---|
double |
nextDouble()
Returns the next pseudo random uniform [0,1] distributed double value
from the stream produced by the underlying pseudo random number
generator.
|
int |
nextInt(int bits)
Returns the next pseudo random integer of a given bit length.
|
long |
nextLong()
Returns the next pseudo random uniform distributed long value
from the stream produced by the underlying pseudo random number
generator.
|
void |
setSeed(long newSeed)
Sets the seed for the pseudo random number generator.
|
void |
twistNumbers()
Internal procedure to create ("twist") 624 new pseudo random numbers
based on the last 624 pseudo random numbers.
|
public MersenneTwisterRandomGenerator()
public MersenneTwisterRandomGenerator(long seed)
seed
- long : The initial seed of the underlying pseudo random
generatorpublic double nextDouble()
nextDouble
in interface UniformRandomGenerator
public long nextLong()
public int nextInt(int bits)
bits
- int : Bit length of the integer to be returnedpublic void twistNumbers()
public void setSeed(long newSeed)
setSeed
in interface UniformRandomGenerator
newSeed
- long : The new initial seed value for the pseudo random number
generator