Pcg 32 Class
Represents a pseudo-random number generator based on the PCG32 XSH-RR algorithm.
Definition
Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.7.0
C#
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.7.0
public sealed class Pcg32 : RandomSource<ScalarGenerator32<Pcg32Engine>>,
IRandomSourceFactory<Pcg32>, IAdvanceable, IJumpable- Inheritance
- Object → RandomSource<ScalarGenerator32<Pcg32Engine>> → Pcg32
- Implements
- IAdvanceable, IJumpable, IRandomSourceFactory<Pcg32>
Remarks
Use the Pcg32 class to represent a pseudo-random number generator that uses the PCG32 XSH-RR (Xorshift-High, Random-Rotate) algorithm by Melissa O'Neill.
This generator features a 64-bit state with a period of 264. The algorithm is very fast and produces very good random sequences. Moreover, it is possible to run several sequences in parallel.
Pcg32 can be used in place of the Random class to obtain pseudo-random numbers of a higher quality.
Note: This generator uses the new Layer 3 architecture with ScalarGenerator32<TEngine> for optimal performance.
Constructors
| Pcg32() | Initializes a new instance of the Pcg32 class using OS entropy. |
| Pcg32( | Initializes a new instance of the Pcg32 class with the specified options. |
| Pcg32( | Initializes a new instance of the Pcg32 class from saved state. |
| Pcg32( | Initializes a new instance of the Pcg32 class with the specified seed. |
| Pcg32( | Initializes a new instance of the Pcg32 class with the specified seed array. |
| Pcg32( | Initializes a new instance of the Pcg32 class with direct state and stream initialization. |
| Pcg32( | Initializes a new instance of the Pcg32 class with the specified seed. |
| Pcg32( | Initializes a new instance of the Pcg32 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) |
| 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 generator forward by a specified number of steps. |
| Copy | Creates a copy of this random number generator with the same state. |
| Create | Creates a new Pcg32 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 | Jumps ahead in the random sequence by an even larger fixed amount. |
| 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 | Returns a random unsigned integer less than the specified value. |
| 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>) |
| Skip | Skips ahead by the specified number of steps. |
| ToString | Returns a string that represents the current object. (Inherited from Object) |