Numpy Seed Sequence Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public sealed class NumpySeedSequence : SeedSequence- Inheritance
- Object → SeedSequence → NumpySeedSequence
Remarks
NumpySeedSequence provides byte-for-byte compatibility with NumPy's numpy.random.SeedSequence class, enabling deterministic seeding that produces identical results across Python (NumPy) and .NET when using the same seed values and stream identifiers.
Algorithm:
The algorithm uses a pool-based mixing design derived from Melissa O'Neill's improved seed_seq design. Input entropy is absorbed into a fixed-size pool (default 4 words) using hash mixing operations with constants INIT_A/MULT_A and INIT_B/MULT_B. The pool is then mixed thoroughly to ensure all bits affect all other bits. Entropy generation cycles through the pool, applying per-position mixing to produce output values.
Pool-Based State:
Unlike SplitMix64-based sequences, NumPy's algorithm maintains a pool of 32-bit words (default size: 4 words) that represents the fully mixed entropy. Output generation cycles through this pool, applying position-dependent mixing to each value. The pool size is fixed at construction and determines the period before cycling.
Usage:
This sequence is selected by Numpy. For explicitly supported generators (PCG64, PCG64-DXSM, SFC64, Philox), it provides full NumPy state compatibility. For other generators, it provides NumPy-compatible entropy expansion.
Reference:
NumPy documentation: https://numpy.org/doc/stable/reference/random/bit_generators/ generated/numpy.random.SeedSequence.html
Melissa O'Neill's PCG paper (Appendix on seeding): https://www.pcg-random.org/paper.html
Constructors
| Numpy | Initializes a new instance of the NumpySeedSequence class with 32-bit entropy values and optional stream address. |
| Numpy | Initializes a new instance of the NumpySeedSequence class with 32-bit entropy values and optional stream address. |
| Numpy | Initializes a new instance of the NumpySeedSequence class with a 64-bit seed and optional stream address. |
Properties
| Pool | Gets the number of 32-bit words in the entropy pool. |
Methods
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Fill( |
Fills a span of 32-bit unsigned integers with entropy
values.
(Overrides SeedSequence.Fill(Span<UInt32>)) |
| Fill( |
Fills a span of 64-bit unsigned integers with entropy
values.
(Overrides SeedSequence.Fill(Span<UInt64>)) |
| Fill(UInt64[]) |
Fills an array of 64-bit unsigned integers with entropy values.
(Inherited from SeedSequence) |
| Fill |
Fills a span of bytes with entropy values.
(Inherited from SeedSequence) |
| Get | Serves as the default hash function. (Inherited from Object) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Next |
Generates the next 32-bit unsigned integer from the entropy
stream.
(Overrides SeedSequence.NextUInt32()) |
| Next |
Generates the next 64-bit unsigned integer from the entropy stream.
(Inherited from SeedSequence) |
| Reset |
Resets the internal state of the entropy stream to the initial state.
(Inherited from SeedSequence) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |
Fields
| Default | The default pool size used by NumPy's SeedSequence. |