SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.pseudorandom.linear
Class LEcuyer

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.pseudorandom.linear.LEcuyer
All Implemented Interfaces:
LinearCongruentialGenerator, RandomLongGenerator, RandomNumberGenerator

public class LEcuyer
extends java.lang.Object
implements LinearCongruentialGenerator

This implements the random number generator recommended by L'Ecuyer in 1996. The generator combines two MRGs. It has a period of approximately 2185.

The first has a modulus m = 231-1 = 2147483647, and a[] = {0, 63308, -183326}.

The second has a modulus m = 2145483479, and a[] = {86098, 0, -539608}.

See Also:
"L'Ecuyer, P. (1996) Combined muliple recursive random number generators. Operations Research 44:816-822."

Field Summary
 long m
          the modulus
 
Constructor Summary
LEcuyer()
          Construct a LEcuyer pseudo uniform random generator.
LEcuyer(long seed11, long seed12, long seed13, long seed21, long seed22, long seed23)
          Construct a LEcuyer pseudo uniform random generator and then seed.
 
Method Summary
 long modulus()
          Get the modulus of this linear congruential generator.
 double nextDouble()
          Get the next random double between 0 and 1.
 long nextLong()
          Get the next random long.
 int order()
          Get the order of recursion.
 void seed(long... seeds)
          Seed the random number generator to produce repeatable sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m

public final long m
the modulus

Constructor Detail

LEcuyer

public LEcuyer()
Construct a LEcuyer pseudo uniform random generator.


LEcuyer

public LEcuyer(long seed11,
               long seed12,
               long seed13,
               long seed21,
               long seed22,
               long seed23)
Construct a LEcuyer pseudo uniform random generator and then seed.

Parameters:
seed11 - a seed
seed12 - a seed
seed13 - a seed
seed21 - a seed
seed22 - a seed
seed23 - a seed
Method Detail

seed

public void seed(long... seeds)
Seed the random number generator to produce repeatable sequences. If there are not enough, i.e., fewer than 6, seeds, we recycle them. If there are more, we take the first 6 and ignore the rest.

Specified by:
seed in interface RandomNumberGenerator
Parameters:
seeds - an array of seeds

order

public int order()
Description copied from interface: LinearCongruentialGenerator
Get the order of recursion.

Specified by:
order in interface LinearCongruentialGenerator
Returns:
the order of recursion

modulus

public long modulus()
Description copied from interface: LinearCongruentialGenerator
Get the modulus of this linear congruential generator.

Specified by:
modulus in interface LinearCongruentialGenerator
Returns:
m

nextLong

public long nextLong()
Description copied from interface: RandomLongGenerator
Get the next random long.

Specified by:
nextLong in interface RandomLongGenerator
Returns:
the next random long

nextDouble

public double nextDouble()
Get the next random double between 0 and 1.

Specified by:
nextDouble in interface RandomNumberGenerator
Returns:
the next random number between 0 and 1

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.