Seed Sequences.Num Py Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
Overload List
| Num | Creates a SeedSequence compatible with NumPy's SeedSequence (v1.17+). |
| Num | Creates a SeedSequence compatible with NumPy's SeedSequence using 32-bit seed words. |
| Num | Creates a SeedSequence compatible with NumPy's SeedSequence (v1.17+) using multiple seed values. |
NumPy(Int64, StreamAddress)
public static SeedSequence NumPy(
long seed,
StreamAddress streamAddress = default
)Parameters
- seed Int64
- The initial seed value.
- streamAddress StreamAddress (Optional)
- Optional stream address for NumPy spawning (empty for root SeedSequence).
Return Value
SeedSequenceA SeedSequence compatible with NumPy SeedSequence.
Remarks
This method creates a seed algorithm that uses ChaCha20-based mixing to provide bit-identical compatibility with NumPy's SeedSequence as of NumPy 1.17.
If streamAddress is empty, creates a root SeedSequence. If streamAddress is provided, all segments are used as spawn_key = (seg0, seg1, ...).
This enables exact reproducibility with Python code using:
# Root: numpy.random.default_rng(seed)
# Spawned: numpy.random.SeedSequence(seed).spawn(n)[streamId]
Example
// Root SeedSequence - matches numpy.random.default_rng(42)
var seedAlgRoot = SeedAlgorithms.NumPy(42);
var rngRoot = new Pcg64(seedAlgRoot);
// Spawned child - matches SeedSequence(42).spawn(5)[3]
var seedAlgSpawned = SeedAlgorithms.NumPy(42, new StreamAddress(3));
var rngSpawned = new Pcg64(seedAlgSpawned);NumPy(ReadOnlySpan<UInt32>, StreamAddress)
public static SeedSequence NumPy(
ReadOnlySpan<uint> seeds,
StreamAddress streamAddress = default
)Parameters
- seeds ReadOnlySpan<UInt32>
- The 32-bit seed words.
- streamAddress StreamAddress (Optional)
- Optional stream address for NumPy spawning (empty for root SeedSequence).
Return Value
SeedSequenceA SeedSequence compatible with NumPy SeedSequence.
Remarks
This method creates a seed algorithm that uses ChaCha20-based mixing to provide bit-identical compatibility with NumPy's SeedSequence as of NumPy 1.17.
The 32-bit words are packed into 64-bit values in little-endian order.
NumPy(ReadOnlySpan<UInt64>, StreamAddress)
public static SeedSequence NumPy(
ReadOnlySpan<ulong> seeds,
StreamAddress streamAddress = default
)Parameters
- seeds ReadOnlySpan<UInt64>
- The initial seed values.
- streamAddress StreamAddress (Optional)
- Optional stream address for NumPy spawning (empty for root SeedSequence).
Return Value
SeedSequenceA SeedSequence compatible with NumPy SeedSequence.
Remarks
This method creates a seed algorithm that uses ChaCha20-based mixing to provide bit-identical compatibility with NumPy's SeedSequence as of NumPy 1.17.
When multiple seeds are provided, only the first seed is used for compatibility with NumPy's single-seed SeedSequence behavior. For full array support, use NumPy's array entropy initialization directly in Python.
If streamAddress is empty, creates a root SeedSequence. If streamAddress is provided, all segments are used as spawn_key = (seg0, seg1, ...).