Mrg 32k 3a Engine Structure
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.5.0
public struct Mrg32k3aEngine : IScalarEngine<uint>,
IRandomEngine, IStateful, IAdvanceable, IJumpable- 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
Mrg32k3aEngine engine = default;
engine.Seed(SeedSequences.SplitMix64(42));
uint value = engine.Next();
// Move to the next classic RngStreams substream.
engine.Jump();Properties
| Bits | Gets the native word size in bits. |
| Jump | Gets the size category of the primary jump operation. |
| Long | Gets the size category of the long jump operation. |
| Name | Gets a human-readable name for this engine. |
| State | Gets the number of bytes required to save/load this engine's state. |
Methods
| Advance() | Advances the engine state by one transition step. |
| Advance( | Advances the RNG state by the specified number of outputs. |
| Equals | Indicates 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. |
| Get | Returns the hash code for this instance. (Inherited from ValueType) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Jump | Jumps the RNG forward by the specified number of primary jump strides. |
| Jump | Advances the engine by the specified number of SimOpt stream jumps (2^141 outputs each). |
| Jump | Advances the engine by the specified number of SimOpt substream jumps (2^94 outputs each). |
| Jump | Advances the engine by one SimOpt subsubstream (2^47 outputs). |
| Load | Loads the engine's state from the source span in a stable little-endian format. |
| Long | 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. |
| Save | Saves the engine's state to the destination span in a stable little-endian format. |
| Seed( | Initializes the engine from 0 to 6 state words, filling omitted values with 1. |
| Seed( | Initializes the engine state from a seed sequence. |
| Seed( | Directly sets the six MRG32k3a state words. |
| ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType) |