Mrg32k3aEngine Structure

Represents an MRG32k3a combined multiple recursive random number generator engine with 32-bit output.

Definition

Namespace: Numerics.NET.Random.Engines
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.5.0
C#
public struct Mrg32k3aEngine : IScalarEngine<uint>, 
	IRandomEngine, IStateful, IAdvanceable, IJumpable
Inheritance
Object  →  ValueType  →  Mrg32k3aEngine
Implements
IRandomEngine, IScalarEngine<UInt32>, IAdvanceable, IJumpable, IStateful

Remarks

The MRG32k3a engine implements Pierre L'Ecuyer's combined multiple recursive generator with two third-order recurrence components. The first component is evaluated modulo 4294967087 and the second component is evaluated modulo 4294944443. The two component values are combined to produce each 32-bit output.

Algorithm Details:

  • State size: 6 unsigned 32-bit words, stored as two 3-word recurrence states.
  • Output size: 32 bits.
  • Output ordering: Advance-then-output.
  • Classic stream hierarchy: Streams are spaced 2127 outputs apart and substreams are spaced 276 outputs apart.

This engine supports deterministic stream partitioning through fixed transition matrices. LongJump(UInt64) applies the classic RngStreams stream jump, and Jump(UInt64) applies the classic RngStreams substream jump. Additional SimOpt jumps are available through JumpSimOptStream(UInt64), JumpSimOptSubstream(UInt64), and JumpSimOptSubsubstream(UInt64) for a three-level hierarchy with 2141, 294, and 247 spacing.

The direct state consists of six words: three for the first recurrence component followed by three for the second component. Each word must be less than the modulus of its component, and neither 3-word component may be all zero.

Reference: Pierre L'Ecuyer, "Good Parameters and Implementations for Combined Multiple Recursive Random Number Generators," 1999.

Example

C#
Mrg32k3aEngine engine = default;
engine.Seed(SeedSequences.SplitMix64(42));

uint value = engine.Next();

// Move to the next classic RngStreams substream.
engine.Jump();

Properties

BitsPerWord Gets the native word size in bits.
JumpSize Gets the size category of the primary jump operation.
LongJumpSize Gets the size category of the long jump operation.
Name Gets a human-readable name for this engine.
StateSize Gets the number of bytes required to save/load this engine's state.

Methods

Advance() Advances the engine state by one transition step.
Advance(UInt64) Advances the RNG state by the specified number of outputs.
EqualsIndicates whether this instance and a specified object are equal.
(Inherited from ValueType)
Fill Fills the destination span with successive native words from the engine's stream.
GetHashCodeReturns the hash code for this instance.
(Inherited from ValueType)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Jump Jumps the RNG forward by the specified number of primary jump strides.
JumpSimOptStream Advances the engine by the specified number of SimOpt stream jumps (2^141 outputs each).
JumpSimOptSubstream Advances the engine by the specified number of SimOpt substream jumps (2^94 outputs each).
JumpSimOptSubsubstream Advances the engine by one SimOpt subsubstream (2^47 outputs).
LoadState Loads the engine's state from the source span in a stable little-endian format.
LongJump Jumps the RNG forward by the specified number of long jump strides.
Next Advances the engine by one step and returns the native word produced for that step.
Output Returns the native word produced by applying the output mapping function to the current engine state, without mutating that state.
SaveState Saves the engine's state to the destination span in a stable little-endian format.
Seed(ReadOnlySpan<UInt32>) Initializes the engine from 0 to 6 state words, filling omitted values with 1.
Seed(SeedSequence) Initializes the engine state from a seed sequence.
Seed(UInt32, UInt32, UInt32, UInt32, UInt32, UInt32) Directly sets the six MRG32k3a state words.
ToStringReturns the fully qualified type name of this instance.
(Inherited from ValueType)

See Also