Split Mix 64 Class
Represents a pseudo-random number generator based on the SplitMix64 algorithm.
Definition
Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public sealed class SplitMix64 : RandomSource<ScalarGenerator64<SplitMix64Engine>>,
IRandomSourceFactory<SplitMix64>, IAdvanceable- Inheritance
- Object → RandomSource<ScalarGenerator64<SplitMix64Engine>> → SplitMix64
- Implements
- IAdvanceable, IRandomSourceFactory<SplitMix64>
Remarks
Use the SplitMix64 class to represent a pseudo-random number generator that uses the SplitMix64 algorithm by Guy Steele and Doug Lea.
This generator is primarily designed for seeding other generators and is compatible with Java's SplittableRandom. It has a period of 264.
The algorithm is fast and produces good quality random sequences, though it is not recommended for highly parallel applications or when cryptographic security is required.
Reference: Guy L. Steele Jr., Doug Lea, and Christine H. Flood. "Fast splittable pseudorandom number generators." OOPSLA 2014.
Example
var rng = new SplitMix64(12345);
double x = rng.NextDouble();
ulong value = rng.NextUInt64();Constructors
| Split | Initializes a new instance of the SplitMix64 class using OS entropy. |
| Split | Initializes a new instance of the SplitMix64 class with the specified options. |
| Split | Initializes a new instance of the SplitMix64 class from saved state. |
| Split | Initializes a new instance of the SplitMix64 class with direct state initialization. |
| Split | Initializes a new instance of the SplitMix64 class with the specified seed. |
| Split | Initializes a new instance of the SplitMix64 class with the specified seed array. |
| Split | Initializes a new instance of the SplitMix64 class with the specified seed. |
| Split | Initializes a new instance of the SplitMix64 class with the specified seed array. |
Properties
| Bits |
Gets the number of bits per word in the generator's native output.
(Overrides RandomSource<TGenerator>.BitsPerWord) |
| 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 SplitMix64 instance from the specified options. |
| 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) |
| Load |
Loads the generator's state from the source span in a stable little-endian format.
(Inherited from RandomSource<TGenerator>) |
| Mix | Applies the SplitMix64 mixing function to a 64-bit value. |
| 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>) |
| 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) |