XorshiftEngine

The Xorshift family of generators, developed by George Marsaglia (2003), offer high-quality random number generation with minimal storage requirements and computational cost. They are therefore highly suitable for use in low-memory environments or slower processors. The current implementation supports Xorshift random number generation with a 32-bit datatype only.

The total number of bits used to store the internal state is reflected in the statistical quality of the resulting generator. The table below lists the number of bits used by each Xorshift generator (which must be a multiple of the datatype size) and the corresponding period of the generator.

$(TEXTWITHCOMMAS Number of $(D bits) used (2nd parameter of $(D_PARAM XorshiftEngine)) and corresponding period of the resulting generator)
bitsperiod
322^32 - 1
642^64 - 1
962^96 - 1
1282^128 - 1
1602^160 - 1
1922^192 - 2^32

Constructors

this
this()

Constructs an XorshiftEngine using the default seed configuration.

this
this(UIntType x0)

Constructs an XorshiftEngine generator seeded with x0.

Members

Functions

front
UIntType front()

Returns the current pseudo-random value.

opEquals
bool opEquals(Object rhs)

Compares against rhs for equality.

popFront
void popFront()

Advances the pseudo-random sequence.

save
typeof(this) save()

Captures a range state.

seed
void seed(UIntType x0)

(Re)seeds the generator with x0.

Variables

empty
enum bool empty;

Always false (random number generators are infinite ranges).

isUniformRandom
enum bool isUniformRandom;

Mark this as a Rng

max
enum UIntType max;

Largest generated value.

min
enum UIntType min;

Smallest generated value (0).

Meta