Class CompositeLinearCongruentialGenerator
java.lang.Object
dev.nm.stat.random.rng.univariate.uniform.linear.CompositeLinearCongruentialGenerator
- All Implemented Interfaces:
RandomLongGenerator
,RandomNumberGenerator
,LinearCongruentialGenerator
,Seedable
public class CompositeLinearCongruentialGenerator
extends Object
implements LinearCongruentialGenerator
A composite generator combines 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 a longer
period, without overflowing the arithmetics.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a linear congruential generator from some simpler and shorter modulus generators. -
Method Summary
Modifier and TypeMethodDescriptionlong
modulus()
Get the modulus of this linear congruential generator.double
Get the next randomdouble
.long
nextLong()
Get the next randomlong
.int
order()
Get the order of recursion.void
seed
(long... seeds) Seed the random number/vector/scenario generator to produce repeatable experiments.
-
Constructor Details
-
CompositeLinearCongruentialGenerator
Constructs a linear congruential generator from some simpler and shorter modulus generators.- Parameters:
rng
- simpler and shorter modulus linear congruential generators
-
-
Method Details
-
seed
public void seed(long... seeds) Description copied from interface:Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments. -
order
public int order()Description copied from interface:LinearCongruentialGenerator
Get the order of recursion.- Specified by:
order
in interfaceLinearCongruentialGenerator
- 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 interfaceLinearCongruentialGenerator
- Returns:
- the modulus
-
nextLong
public long nextLong()Description copied from interface:RandomLongGenerator
Get the next randomlong
.- Specified by:
nextLong
in interfaceRandomLongGenerator
- Returns:
- the next random
long
-
nextDouble
public double nextDouble()Description copied from interface:RandomNumberGenerator
Get the next randomdouble
.- Specified by:
nextDouble
in interfaceRandomNumberGenerator
- Returns:
- the next random number
-