net.sourceforge.cilib.math.random.generator
Class MersenneTwister

java.lang.Object
  extended by java.util.Random
      extended by net.sourceforge.cilib.math.random.generator.Random
          extended by net.sourceforge.cilib.math.random.generator.MersenneTwister
All Implemented Interfaces:
Serializable, Cloneable

public class MersenneTwister
extends Random

This is an implementation of the MT19937 random number generator.

The MT19937 generator of Makoto Matsumoto and Takuji Nishimura is a variant of the twisted generalized feedback shift-register algorithm, and is known as the "Mersenne Twister" generator. It has a Mersenne prime period of 2^19937 - 1 (about 10^6000) and is equi-distributed in 623 dimensions. It has passed the DIEHARD statistical tests. It uses 624 words of state per generator and is comparable in speed to the other simulation quality generators. The original generator used a default seed of 4357 and setting the seed equal to zero

- Brian Gough

reproduces this. References:

This code is based on the implementation in GSL (GNU Scientific Library) which is also covered by the GNU General Public License. The original C source code is Copyright (C) 1998 Brian Gough. Comment text ripped from GSL.

Author:
Edwin Peer
See Also:
Serialized Form

Constructor Summary
MersenneTwister()
          Default Constructor.
MersenneTwister(long seed)
          Create a MersenneTwister with the given seed value.
MersenneTwister(MersenneTwister copy)
          Copy constructor.
 
Method Summary
 MersenneTwister getClone()
          Get a cloned instance of the current object.
protected  int next(int bits)
          
 double nextDouble()
          
 void setSeed(long seed)
          
 
Methods inherited from class java.util.Random
nextBoolean, nextBytes, nextFloat, nextGaussian, nextInt, nextInt, nextLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MersenneTwister

public MersenneTwister()
Default Constructor. Initialises the MersenneTwister with the seed value from Seeder.getSeed().


MersenneTwister

public MersenneTwister(long seed)
Create a MersenneTwister with the given seed value.

Parameters:
seed - The initial seed value to use.

MersenneTwister

public MersenneTwister(MersenneTwister copy)
Copy constructor. Create an instance with the same seed as the given instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public MersenneTwister getClone()
Get a cloned instance of the current object.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in class Random
Returns:
The cloned instance.
See Also:
Object.clone()

setSeed

public void setSeed(long seed)

Overrides:
setSeed in class Random

next

protected int next(int bits)

Overrides:
next in class Random

nextDouble

public double nextDouble()

Overrides:
nextDouble in class Random


Copyright © 2009 CIRG. All Rights Reserved.