public class Congruential extends java.lang.Object implements RandomNumber
CongruentialSeeds produces the
same streams as the random number generator in SIMCRIPT.
This generator has a period of 2147483647 for any starting seed.
LKSeeds contains seeds for 100 streams spaced 100,000 apart.| Modifier and Type | Field and Description |
|---|---|
private long |
currentSeed |
static long |
MODULUS |
static double |
MULT |
static long |
MULTIPLIER |
private long |
startingSeed |
| Constructor and Description |
|---|
Congruential()
Contructs a new Congruential with the starting seed of the first stream.
|
| Modifier and Type | Method and Description |
|---|---|
double |
draw()
Generates and returns the next U(0,1) random variate.
|
long |
drawLong()
Generates and returns the next random number.
|
double |
getMultiplier()
Returns the value for this RandomNumber needed to scale
a number produced by drawLong to result in U(0,1).
|
long |
getSeed()
Returns the current seed.
|
long[] |
getSeeds()
Returns a one element array containing the current seed.
|
void |
resetSeed()
Resets the seed to its original value.
|
void |
setSeed(long seed)
Sets the seed to the given value.
|
void |
setSeeds(long[] seed)
Sets the starting seed to the value contained in the first
element of the array.
|
java.lang.String |
toString()
Returns a String containing the type of generator and the current seed.
|
public static final long MODULUS
public static final long MULTIPLIER
public static final double MULT
private long startingSeed
private long currentSeed
public Congruential()
public void setSeed(long seed)
setSeed in interface RandomNumberseed - The new random number seedpublic long getSeed()
getSeed in interface RandomNumberpublic void resetSeed()
resetSeed in interface RandomNumberpublic void setSeeds(long[] seed)
setSeeds in interface RandomNumberseed - The new array of seedsjava.lang.IllegalArgumentException - If the array has zero length.public long[] getSeeds()
getSeeds in interface RandomNumberpublic long drawLong()
drawLong in interface RandomNumberpublic double draw()
draw in interface RandomNumberpublic java.lang.String toString()
toString in class java.lang.Objectpublic double getMultiplier()
RandomNumbergetMultiplier in interface RandomNumber