C# Class Encog.MathUtil.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
Afficher le fichier Open project: encog/encog-silverlight-core Class Usage Examples

Méthodes publiques

Méthode Description
LinearCongruentialGenerator ( long seed ) : System

Construct the default LCG. You need only specify a seed.

LinearCongruentialGenerator ( long modulus, long multiplier, long increment, long seed ) : System

Create a LCG with the specified modulus, multiplier and increment. Unless you REALLY KNOW WHAT YOU ARE DOING, just use the constructor that just takes a seed. It will set these values to the same as set by the GCC C compiler. Setting these values wrong can create fairly useless random numbers.

NextDouble ( ) : double

The next random number as a double between 0 and 1.

NextLong ( ) : long

The next random number as a long between 0 and MAX_RAND.

Range ( double min, double max ) : double

Generate a random number in the specified range.

Method Details

LinearCongruentialGenerator() public méthode

Construct the default LCG. You need only specify a seed.
public LinearCongruentialGenerator ( long seed ) : System
seed long The seed.
Résultat System

LinearCongruentialGenerator() public méthode

Create a LCG with the specified modulus, multiplier and increment. Unless you REALLY KNOW WHAT YOU ARE DOING, just use the constructor that just takes a seed. It will set these values to the same as set by the GCC C compiler. Setting these values wrong can create fairly useless random numbers.
public LinearCongruentialGenerator ( long modulus, long multiplier, long increment, long seed ) : System
modulus long The modulus for the LCG algorithm.
multiplier long The multiplier for the LCG algorithm.
increment long The increment for the LCG algorithm.
seed long The seed for the LCG algorithm. Using the same seed will give /// the same random number sequence each time, whether in Java or /// DotNet.
Résultat System

NextDouble() public méthode

The next random number as a double between 0 and 1.
public NextDouble ( ) : double
Résultat double

NextLong() public méthode

The next random number as a long between 0 and MAX_RAND.
public NextLong ( ) : long
Résultat long

Range() public méthode

Generate a random number in the specified range.
public Range ( double min, double max ) : double
min double The minimum random number.
max double The maximum random number.
Résultat double