SuanShu, a Java numerical and statistical library

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

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

public class CombinedLinearCongruentialGenerator
extends java.lang.Object
implements LinearCongruentialGenerator

This class takes a number of simple LinearCongruentialGenerator, such as Lehmer, to form one longer period generator by first summing values and then taking modulus. The resultant generator in general has a superior uniformity and longer period, without overflowing the arithmetics.


Constructor Summary
CombinedLinearCongruentialGenerator(LinearCongruentialGenerator[] rng)
          Construct a linear congruential generator from some simpler and shorter modulus generators.
 
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
 

Constructor Detail

CombinedLinearCongruentialGenerator

public CombinedLinearCongruentialGenerator(LinearCongruentialGenerator[] rng)
Construct a linear congruential generator from some simpler and shorter modulus generators.

Parameters:
rng - an array of LinearCongruentialGenerators
Method Detail

seed

public void seed(long... seeds)
Description copied from interface: RandomNumberGenerator
Seed the random number generator to produce repeatable sequences.

Specified by:
seed in interface RandomNumberGenerator
Parameters:
seeds - the 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.