|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.encog.mathutil.LinearCongruentialGenerator
public class LinearCongruentialGenerator
A predictable random number generator. This is useful for unit tests and benchmarks where we want random numbers, but we want them to be the same each time. This class exists on both Java and C# so it can even provide consistent random numbers over the two platforms. Random numbers are created using a LCG. http://en.wikipedia.org/wiki/Linear_congruential_generator
Field Summary | |
---|---|
static long |
DEFAULT_INC
Default inc. |
static long |
DEFAULT_MOD1
First part of default mod. |
static long |
DEFAULT_MOD2
Second part of default mod. |
static long |
DEFAULT_MULT
Default mult. |
static long |
MAX_RAND
The maximum rand number that the standard GCC based LCG will generate. |
Constructor Summary | |
---|---|
LinearCongruentialGenerator(long theSeed)
Construct the default LCG. |
|
LinearCongruentialGenerator(long theModulus,
long theMultiplier,
long theIncrement,
long theSeed)
Create a LCG with the specified modulus, multiplier and increment. |
Method Summary | |
---|---|
long |
getIncrement()
|
long |
getModulus()
|
long |
getMultiplier()
|
long |
getSeed()
|
double |
nextDouble()
|
long |
nextLong()
|
double |
range(double min,
double max)
Generate a random number in the specified range. |
void |
setSeed(long theSeed)
Set the seed value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULT_MOD1
public static final long DEFAULT_MOD2
public static final long DEFAULT_MULT
public static final long DEFAULT_INC
public static final long MAX_RAND
Constructor Detail |
---|
public LinearCongruentialGenerator(long theSeed)
theSeed
- The seed to use.public LinearCongruentialGenerator(long theModulus, long theMultiplier, long theIncrement, long theSeed)
theModulus
- The modulus for the LCG algorithm.theMultiplier
- The multiplier for the LCG algorithm.theIncrement
- The increment for the LCG algorithm.theSeed
- The seed for the LCG algorithm. Using the same seed will give
the same random number sequence each time, whether in Java or
DotNet.Method Detail |
---|
public final long getIncrement()
public final long getModulus()
public final long getMultiplier()
public final long getSeed()
public final double nextDouble()
public final long nextLong()
public final double range(double min, double max)
min
- The minimum random number.max
- The maximum random number.
public final void setSeed(long theSeed)
theSeed
- The seed value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |