Pcg 64Dxsm Engine Structure
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public struct Pcg64DxsmEngine : IScalarEngine<ulong>,
IRandomEngine, IStateful, IAdvanceable, IJumpable- Implements
- IRandomEngine, IScalarEngine<UInt64>, IAdvanceable, IJumpable, IStateful
Remarks
The PCG64 DXSM (Double XorShift Multiply) engine uses a 128-bit linear congruential generator (LCG) with the cheap multiplier 0xda942042e4dd58b5. It features a 128-bit state with a period of 2128 and provides excellent statistical quality with superior performance characteristics.
Algorithm Details:
- State size: 128 bits (state + increment)
- Output function: DXSM (Double XorShift Multiply)
- Multiplier: 0xda942042e4dd58b5 (64-bit "cheap" multiplier)
- Period: 2128
- Output ordering: Output-then-advance (outputs from state before advancing)
Compatibility:
This engine is compatible with NumPy 1.18+ PCG64DXSM and serves as the recommended PCG64 variant for new code requiring the highest statistical quality. The DXSM output function provides superior statistical properties compared to other PCG variants.
Performance:
Excellent performance with the best statistical properties in the PCG family. The "cheap" multiplier provides faster execution than full 128-bit multiplication while the DXSM output function ensures superior statistical quality. Supports efficient advancement and jumping operations for parallel stream generation.
Reference: Melissa E. O'Neill. "PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation." Harvey Mudd College, 2014.
See also: https://www.pcg-random.org/ and https://numpy.org/doc/stable/reference/random/bit_generators/pcg64dxsm.html
Example
var engine = new Pcg64DxsmEngine();
engine.Seed(SeedSequences.SplitMix64(42));
ulong value = engine.Next();
ulong[] values = new ulong[100];
engine.Fill(values);
byte[] bytes = new byte[1000];
engine.Fill(bytes.AsSpan());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. |
| 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 state from a seed sequence. |
| Seed( | Directly sets the PCG64 DXSM 128-bit state and stream. |
| Seed( | Directly sets the PCG64 DXSM 128-bit state and stream. |
| ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType) |