nn::math::MersenneTwister Class

Header file: nn/math.h

Syntax

class MersenneTwister

Description

A random number generator class using the Mersenne twister.

The Mersenne twister is a random number generating algorithm that generates superior pseudo-random numbers, but it requires an internal state of roughly 2.5 KB.

This class uses the same parameters as mt19937, and the same initial state is obtained upon initialization.

Because the size of this class is large, caution is needed when allocating it on the stack.

The random number cycle is 2^19937 - 1.

Structures

nn::math::MersenneTwister::State Structure for saving the internal state of random number generation.

Member Functions

Initialization and Finalization
Initialize Performs initialization.
Finalize Performs finalization.
State Saving and Restoration
SaveState Saves the internal state.
RestoreState Restores the internal state.
Random Number Generation
GenerateRandomU32 Generates an unsigned 32-bit random integer.
GenerateRandomU64 Generates an unsigned 64-bit random integer.
GenerateRandomF32 Generates a single, precision floating-point random number.
GenerateRandomF64 Generates a double, precision floating-point random number.
GenerateRandomN Generates a random number that is less than the specified number.
GenerateRandomBytes Generates a series of random bytes.

Revision History

2012/05/11
Initial version.

CONFIDENTIAL