Pcg 64Dxsm Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public sealed class Pcg64Dxsm : RandomSource<ScalarGenerator64<Pcg64DxsmEngine>>,
IRandomSourceFactory<Pcg64Dxsm>, IAdvanceable, IJumpable- Inheritance
- Object → RandomSource<ScalarGenerator64<Pcg64DxsmEngine>> → Pcg64Dxsm
- Implements
- IAdvanceable, IJumpable, IRandomSourceFactory<Pcg64Dxsm>
Remarks
Use the Pcg64Dxsm class to represent a pseudo-random number generator that uses the PCG64 DXSM (Double XorShift Multiply) algorithm by Melissa O'Neill.
This generator features a 128-bit state with a period of 2128. It passes the strictest statistical tests including BigCrush and PractRand, and provides excellent statistical properties and performance.
Algorithm details:
- LCG: 128-bit state
- Multiplier: 0xDA942042E4DD58B5 (64-bit "cheap" multiplier)
- Output function: DXSM (Double Xorshift Multiply)
- Output ordering: output-then-advance (outputs from state before advancing)
The DXSM variant provides the best overall statistical quality of the PCG family. It uses a 64-bit "cheap" multiplier which provides excellent performance while the DXSM output function ensures superior statistical properties.
Use case: This is the recommended PCG64 variant for new code requiring the highest statistical quality. It matches NumPy 1.18+ PCG64DXSM implementation and is the default generator in NumPy's modern random API.
Compatibility note: This generator will produce different sequences than Pcg64 even with the same seed, due to the different multiplier and output function.
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://numpy.org/doc/stable/reference/random/bit_generators/pcg64dxsm.html
Example
var rng = new Pcg64Dxsm(42);
double x = rng.NextDouble();
ulong bits = rng.NextUInt64();Constructors
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class using OS entropy. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with the specified options. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class from saved state. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with the specified seed. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with the specified seed array. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with direct state and stream initialization. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with the specified seed. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with the specified seed array. |
| Pcg6 | Initializes a new instance of the Pcg64Dxsm class with direct state and stream initialization. |
Properties
| Bits |
Gets the number of bits per word in the generator's native output.
(Overrides RandomSource<TGenerator>.BitsPerWord) |
| 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 random number generator.
(Overrides RandomSource<TGenerator>.Name) |
| State |
Gets the number of bytes required to save/load this generator's state.
(Inherited from RandomSource<TGenerator>) |
| Uncached |
Gets an uncached facade for this random number generator.
(Inherited from RandomSource<TGenerator>) |
Methods
| Advance | Advances the RNG state by the specified number of outputs. |
| Copy | Returns a deep copy of this RNG. |
| Create | Creates a new Pcg64Dxsm instance from the specified options. |
| Create | Creates a jump-based stream partition for generating independent RNG streams. |
| Create | Creates a hierarchical stream tree for generating independent RNG streams. |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Fill( |
Fills a span with random 32-bit unsigned integer values.
(Inherited from RandomSource<TGenerator>) |
| Fill( |
Fills a span with random 32-bit signed integers less than the specified maximum.
(Inherited from RandomSource<TGenerator>) |
| Fill( |
Fills a span with random 64-bit signed integers less than the specified maximum.
(Inherited from RandomSource<TGenerator>) |
| Fill( |
Fills a span with random 32-bit signed integers within a specified range.
(Inherited from RandomSource<TGenerator>) |
| Fill( |
Fills a span with random 64-bit signed integers within a specified range.
(Inherited from RandomSource<TGenerator>) |
| Get | Serves as the default hash function. (Inherited from Object) |
| Get |
Returns the current state of the generator as a byte array.
(Inherited from RandomSource<TGenerator>) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Jumped | Returns a new instance of the random number generator that is advanced by a specified number of jumps in the sequence. |
| Load |
Loads the generator's state from the source span in a stable little-endian format.
(Inherited from RandomSource<TGenerator>) |
| Long | Returns a new instance of the random number generator that is advanced by a specified number of long jumps in the sequence. |
| Next() |
Returns a non-negative random integer.
(Inherited from RandomSource<TGenerator>) |
| Next( |
Returns a non-negative random integer less than the specified maximum.
(Inherited from RandomSource<TGenerator>) |
| Next( |
Returns a random integer within a specified range.
(Inherited from RandomSource<TGenerator>) |
| Next |
Fills the elements of a specified array of bytes with random numbers.
(Inherited from RandomSource<TGenerator>) |
| Next |
Fills the elements of a specified span of bytes with random numbers.
(Inherited from RandomSource<TGenerator>) |
| Next |
Fills the elements of a specified span of bytes with random numbers.
(Inherited from RandomSource<TGenerator>) |
| Next |
Fills the elements of a specified span of bytes with random numbers.
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a random floating-point number in the range [0.0, 1.0).
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a non-negative random 64-bit integer.
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a non-negative random 64-bit integer less than the specified maximum.
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a random 64-bit integer within a specified range.
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a random single-precision floating-point number in the range [0.0, 1.0).
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a random 32-bit unsigned integer.
(Inherited from RandomSource<TGenerator>) |
| Next |
Returns a random 64-bit unsigned integer.
(Inherited from RandomSource<TGenerator>) |
| Numpy | Advances this generator by the equivalent of count NumPy PCG64DXSM jumps. |
| Reinitialize |
Reinitializes this random number generator using the specified initialization options.
(Inherited from RandomSource<TGenerator>) |
| Save |
Saves the generator's state to the destination span in a stable little-endian format.
(Inherited from RandomSource<TGenerator>) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |