Namespaces

Types in MathNet.Numerics.Random

Type Xorshift

Namespace MathNet.Numerics.Random

Parent RandomSource

Implements a multiply-with-carry Xorshift pseudo random number generator (RNG) specified in Marsaglia, George. (2003). Xorshift RNGs. Xn = a * Xn−3 + c mod 2^32 http://www.jstatsoft.org/v08/i14/paper

Constructors

Static Functions

Methods

Public Constructors

Xorshift(int seed, bool threadSafe, long a, long c, long x1, long x2)

Initializes a new instance of the Xorshift class.
c must be less than a.
Parameters
int seed

The seed value.

bool threadSafe

if set to true , the class is thread safe.

long a

The multiply value

long c

The initial carry value.

long x1

The initial value if X1.

long x2

The initial value if X2.

Xorshift(int seed, long a, long c, long x1, long x2)

Initializes a new instance of the Xorshift class.
If the seed value is zero, it is set to one. Uses the value of ThreadSafeRandomNumberGenerators to set whether the instance is thread safe.
Parameters
int seed

The seed value.

long a

The multiply value

long c

The initial carry value.

long x1

The initial value if X1.

long x2

The initial value if X2.

Xorshift(int seed)

Initializes a new instance of the Xorshift class.
If the seed value is zero, it is set to one. Uses the value of ThreadSafeRandomNumberGenerators to set whether the instance is thread safe. Uses the default values of:
Parameters
int seed

The seed value.

Xorshift(bool threadSafe, long a, long c, long x1, long x2)

Initializes a new instance of the Xorshift class using a seed based on time and unique GUIDs.
c must be less than a.
Parameters
bool threadSafe

if set to true , the class is thread safe.

long a

The multiply value

long c

The initial carry value.

long x1

The initial value if X1.

long x2

The initial value if X2.

Xorshift(bool threadSafe)

Initializes a new instance of the Xorshift class using a seed based on time and unique GUIDs.
Uses the default values of:
Parameters
bool threadSafe

if set to true , the class is thread safe.

Xorshift(long a, long c, long x1, long x2)

Initializes a new instance of the Xorshift class using a seed based on time and unique GUIDs.
If the seed value is zero, it is set to one. Uses the value of ThreadSafeRandomNumberGenerators to set whether the instance is thread safe. Note: c must be less than a.
Parameters
long a

The multiply value

long c

The initial carry value.

long x1

The initial value if X1.

long x2

The initial value if X2.

Xorshift()

Initializes a new instance of the Xorshift class using a seed based on time and unique GUIDs.
If the seed value is zero, it is set to one. Uses the value of ThreadSafeRandomNumberGenerators to set whether the instance is thread safe. Uses the default values of:

Xorshift(int seed, bool threadSafe)

Initializes a new instance of the Xorshift class.
Uses the default values of:
Parameters
int seed

The seed value.

bool threadSafe

if set to true , the class is thread safe.

Public Static Functions

void Doubles(Double[] values, int seed, ulong a, ulong c, ulong x1, ulong x2)

Fills an array with random numbers greater than or equal to 0.0 and less than 1.0.
Supports being called in parallel from multiple threads.

Double[] Doubles(int length, int seed, ulong a, ulong c, ulong x1, ulong x2)

Returns an array of random numbers greater than or equal to 0.0 and less than 1.0.
Supports being called in parallel from multiple threads.

IEnumerable<double> DoubleSequence(int seed, ulong a, ulong c, ulong x1, ulong x2)

Returns an infinite sequence of random numbers greater than or equal to 0.0 and less than 1.0.
Supports being called in parallel from multiple threads, but the result must be enumerated from a single thread each.

Public Methods

bool Equals(object obj)

int GetHashCode()

Type GetType()

void NextBytes(Byte[] buffer)

Fills the elements of a specified array of bytes with random numbers.
Parameters
Byte[] buffer

An array of bytes to contain random numbers.

double NextDouble()

Double[] NextDoubles(int count)

Returns an array of uniform random numbers greater than or equal to 0.0 and less than 1.0.
Parameters
int count

The size of the array to fill.

void NextDoubles(Double[] values)

Fills an array with uniform random numbers greater than or equal to 0.0 and less than 1.0.
Parameters
Double[] values

The array to fill with random values.

IEnumerable<double> NextDoubleSequence()

Returns an infinite sequence of uniform random numbers greater than or equal to 0.0 and less than 1.0.

Int32[] NextInt32s(int count, int minInclusive, int maxExclusive)

Returns an array with random 32-bit signed integers within the specified range.
Parameters
int count

The size of the array to fill.

int minInclusive

The inclusive lower bound of the random number returned.

int maxExclusive

The exclusive upper bound of the random number returned. Range: maxExclusive > minExclusive.

void NextInt32s(Int32[] values, int minInclusive, int maxExclusive)

Fills an array with random numbers within a specified range.
Parameters
Int32[] values

The array to fill with random values.

int minInclusive

The inclusive lower bound of the random number returned.

int maxExclusive

The exclusive upper bound of the random number returned. Range: maxExclusive > minExclusive.

Int32[] NextInt32s(int count, int maxExclusive)

Returns an array with random 32-bit signed integers within the specified range.
Parameters
int count

The size of the array to fill.

int maxExclusive

The exclusive upper bound of the random number returned. Range: maxExclusive ≥ 1.

void NextInt32s(Int32[] values, int maxExclusive)

Fills an array with random numbers within a specified range.
Parameters
Int32[] values

The array to fill with random values.

int maxExclusive

The exclusive upper bound of the random number returned. Range: maxExclusive ≥ 1.

Int32[] NextInt32s(int count)

Returns an array with random 32-bit signed integers greater than or equal to zero and less than MaxValue.
Parameters
int count

The size of the array to fill.

void NextInt32s(Int32[] values)

Fills an array with random 32-bit signed integers greater than or equal to zero and less than MaxValue.
Parameters
Int32[] values

The array to fill with random values.

IEnumerable<int> NextInt32Sequence()

Returns an infinite sequence of random 32-bit signed integers greater than or equal to zero and less than MaxValue.

IEnumerable<int> NextInt32Sequence(int minInclusive, int maxExclusive)

Returns an infinite sequence of random numbers within a specified range.
Parameters
int minInclusive

The inclusive lower bound of the random number returned.

int maxExclusive

The exclusive upper bound of the random number returned. Range: maxExclusive > minExclusive.

string ToString()