Twister

Wrapper for the Mersenne twister.

The Mersenne twister is a pseudorandom number generator linked to CR developed in 1997 by Makoto Matsumoto and Takuji Nishimura that is based on a matrix linear recurrence over a finite binary field F2. It provides for fast generation of very high quality pseudorandom numbers, having been designed specifically to rectify many of the flaws found in older algorithms.

Mersenne Twister has the following desirable properties:

1. It was designed to have a period of 2^19937 - 1 (the creators
   of the algorithm proved this property).

2. It has a very high order of dimensional equidistribution.
   This implies that there is negligible serial correlation between
   successive values in the output sequence.

3. It passes numerous tests for statistical randomness, including
   the stringent Diehard tests.

4. It is fast.

Members

Functions

addEntropy
void addEntropy(uint delegate() r)

adds entropy to the generator

fromString
size_t fromString(const(char[]) s)

reads the current status from a string (that should have been trimmed) returns the number of chars read

next
uint next()

returns a random uint

nextB
ubyte nextB()

returns a random byte

nextL
ulong nextL()

returns a random long

seed
void seed(uint delegate() r)

seeds the generator

seed
void seed(uint s)

initializes the generator with a uint as seed

toString
immutable(char)[] toString()

writes the current status in a string

Variables

canCheckpoint
enum int canCheckpoint;
Undocumented in source.
canSeed
enum int canSeed;
Undocumented in source.

Meta