C# Класс 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
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

LinearCongruentialGenerator() публичный Метод

Construct the default LCG. You need only specify a seed.
public LinearCongruentialGenerator ( long seed ) : System
seed long The seed.
Результат System

LinearCongruentialGenerator() публичный Метод

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.
Результат System

NextDouble() публичный Метод

The next random number as a double between 0 and 1.
public NextDouble ( ) : double
Результат double

NextLong() публичный Метод

The next random number as a long between 0 and MAX_RAND.
public NextLong ( ) : long
Результат long

Range() публичный Метод

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.
Результат double