org.jscience.measure.random
Class EcuyerGenerator

java.lang.Object
  extended by org.jscience.measure.random.RandomElement
      extended by org.jscience.measure.random.RandomSeedable
          extended by org.jscience.measure.random.EcuyerGenerator
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, RandomGenerator

public class EcuyerGenerator
extends RandomSeedable
implements java.io.Serializable

Ranecu is an advanced multiplicative linear congruential random number generator with a period of aproximately 1018. Ranecu is a direct translation from Fortran of the RANECU subroutine published in the paper
F. James, Comp. Phys. Comm. 60 (1990) p 329-344
The algorithm was originally described in
P. L'Ecuyer, Commun. ACM. 1988 (1988) p 742

Source code is available.

See Also:
Serialized Form

Field Summary
static int DEFSEED1
          default iseed1 = 12345
static int DEFSEED2
          default iseed2 = 67890
 
Constructor Summary
EcuyerGenerator()
          Initialize RANECU with the default seeds from James.
EcuyerGenerator(java.util.Date d)
           
EcuyerGenerator(int s1, int s2)
          Initialize RANECU with two specified integer seeds.
EcuyerGenerator(long l)
           
 
Method Summary
 long getSeed()
           
 double nextDouble()
          Generate a random scalar with null mean and unit standard deviation.
 void nextDouble(double[] d, int n)
          This is an inline version that returns an array of doubles for speed.
 
Methods inherited from class org.jscience.measure.random.RandomSeedable
ClockSeed, ClockSeed
 
Methods inherited from class org.jscience.measure.random.RandomElement
choose, choose, clone, coin, coin, gaussian, gaussian, nextDouble, powlaw, uniform
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFSEED1

public static int DEFSEED1
default iseed1 = 12345


DEFSEED2

public static int DEFSEED2
default iseed2 = 67890

Constructor Detail

EcuyerGenerator

public EcuyerGenerator()
Initialize RANECU with the default seeds from James.


EcuyerGenerator

public EcuyerGenerator(int s1,
                       int s2)
Initialize RANECU with two specified integer seeds. Use this to introduce repeatable seeds. Equivalent to

Ranecu(s1*(long) Integer.MAX_VALUE)+s2)

Parameters:
s1 - seed integer 1 (MSW)
s2 - seed integer 2 (LSW)

EcuyerGenerator

public EcuyerGenerator(long l)

EcuyerGenerator

public EcuyerGenerator(java.util.Date d)
Method Detail

nextDouble

public final double nextDouble()
Description copied from interface: RandomGenerator
Generate a random scalar with null mean and unit standard deviation.

This method does not specify the shape of the distribution, it is the implementing class that provides it. The only contract here is to generate numbers with null mean and unit standard deviation.

Specified by:
nextDouble in interface RandomGenerator
Returns:
a random scalar
See Also:
RandomElement.nextDouble(double[], int)

nextDouble

public final void nextDouble(double[] d,
                             int n)
This is an inline version that returns an array of doubles for speed.

Overrides:
nextDouble in class RandomElement
Parameters:
d - array to be filled with doubles
n - number of doubles to generate

getSeed

public long getSeed()
Returns:
the current generator state as a long. Can be used to restart the generator where one left off.