etomica.util
Class RandomMersenneTwister

java.lang.Object
  extended by etomica.util.RandomMersenneTwister
All Implemented Interfaces:
IRandom

public class RandomMersenneTwister
extends Object
implements IRandom

Mersenne Twister RNG. seed initialization and nextInt() methods written in C by Takuji Nishimura and Makoto Matsumoto as described above, and translated into Java. Other methods added for the Java version.


Field Summary
protected  boolean hasNextGaussian
           
protected static int LOWER_MASK
           
protected static int M
           
protected static int MATRIX_A
           
protected  int[] mt
           
protected  int mti
           
protected static int N
           
protected  double nextGaussian
           
protected static int UPPER_MASK
           
 
Constructor Summary
RandomMersenneTwister(int s)
          Creates a Mersenne Twister with the given seed.
RandomMersenneTwister(int[] s)
          Creates a Mersenne Twister with the given array of seeds.
 
Method Summary
 double nextDouble()
          Returns a pseudorandom double, uniformly distributed between 0.0 (inclusive) and 1.0 (exclusive).
 float nextFloat()
           
 double nextGaussian()
          Returns a pseudorandom double, Gaussian ("normally") distributed value with mean 0.0 and standard deviation 1.0.
 int nextInt()
           
 int nextInt(int max)
          Returns a random int ranging from 0 to max-1.
 long nextLong()
           
 void setSeed(int s)
          Configures the RNG with the given seed.
 void setSeedArray(int[] init_key)
          Configures the RNG with an array of seeds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

protected static final int N
See Also:
Constant Field Values

M

protected static final int M
See Also:
Constant Field Values

MATRIX_A

protected static final int MATRIX_A
See Also:
Constant Field Values

UPPER_MASK

protected static final int UPPER_MASK
See Also:
Constant Field Values

LOWER_MASK

protected static final int LOWER_MASK
See Also:
Constant Field Values

mt

protected final int[] mt

mti

protected int mti

hasNextGaussian

protected boolean hasNextGaussian

nextGaussian

protected double nextGaussian
Constructor Detail

RandomMersenneTwister

public RandomMersenneTwister(int s)
Creates a Mersenne Twister with the given seed.


RandomMersenneTwister

public RandomMersenneTwister(int[] s)
Creates a Mersenne Twister with the given array of seeds.

Method Detail

setSeed

public void setSeed(int s)
Configures the RNG with the given seed.


setSeedArray

public void setSeedArray(int[] init_key)
Configures the RNG with an array of seeds


nextInt

public int nextInt()

nextLong

public long nextLong()

nextInt

public int nextInt(int max)
Returns a random int ranging from 0 to max-1.

Specified by:
nextInt in interface IRandom

nextDouble

public double nextDouble()
Description copied from interface: IRandom
Returns a pseudorandom double, uniformly distributed between 0.0 (inclusive) and 1.0 (exclusive).

Specified by:
nextDouble in interface IRandom

nextGaussian

public double nextGaussian()
Description copied from interface: IRandom
Returns a pseudorandom double, Gaussian ("normally") distributed value with mean 0.0 and standard deviation 1.0.

Specified by:
nextGaussian in interface IRandom

nextFloat

public float nextFloat()