JGAP

org.jgap.util
Class randomMCG

java.lang.Object
  extended by org.jgap.util.randomX
      extended by org.jgap.util.randomMCG

public class randomMCG
extends randomX

Implementation of a randomX-compliant class using the "Minimal Standard" multiplicative congruential generator of Park and Miller. [Park, S.K. and K.W. Miller, Communications of the ACM 31, 1192-1201 (1988).]

The generation algorithm is:

Ij+1 = (Ij × 16807) & 0x7FFFFFFF

Note that the intermediate value of the multiplication by 16807 (75) exceeds that representable in 32 bits; this has deterred use of this generator in most portable languages. Fortunately, Java's long type is guaranteed to be 64 bits, so a straightforward and portable implementation is possible.

Designed and implemented in July 1996 by John Walker, kelvin@fourmilab.ch.


Constructor Summary
randomMCG()
          Creates a new pseudorandom number generator, seeded from the current time.
randomMCG(long seed)
          Creates a new pseudorandom number generator with a specified nonzero seed.
 
Method Summary
 byte nextByte()
          Get next byte from generator.
 void setSeed(long seed)
          Set seed for generator.
 
Methods inherited from class org.jgap.util.randomX
nextBit, nextByte, nextByte, nextDouble, nextFloat, nextGaussian, nextInt, nextLong, nextShort, setSeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

randomMCG

public randomMCG()
Creates a new pseudorandom number generator, seeded from the current time.


randomMCG

public randomMCG(long seed)
          throws java.lang.IllegalArgumentException
Creates a new pseudorandom number generator with a specified nonzero seed.

Parameters:
seed - initial seed for the generator
Throws:
java.lang.IllegalArgumentException
Method Detail

setSeed

public void setSeed(long seed)
             throws java.lang.IllegalArgumentException
Set seed for generator. Subsequent values will be based on the given nonzero seed.

Parameters:
seed - seed for the generator
Throws:
java.lang.IllegalArgumentException

nextByte

public byte nextByte()
Get next byte from generator.

Specified by:
nextByte in class randomX
Returns:
the next byte from the generator.

JGAP