Random Streams.Create Streams Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
Overload List
| Create | Creates an array of random number generators using mixing-based stream derivation. |
| Create | Creates an array of random number generators from a scalar seed. |
| Create | Creates an array of random number generators from a seed array. |
CreateStreams<TRandom>(Int32, RandomOptions, UInt64)
public static TRandom[] CreateStreams<TRandom>(
int count,
in RandomOptions options,
ulong startIndex = 0
)
where TRandom : Object, IRandomSourceFactory<TRandom>
Parameters
- count Int32
- The number of generators to create (must be non-negative).
- options RandomOptions
- The initialization options containing seed and stream address.
- startIndex UInt64 (Optional)
- The starting index for stream enumeration (default is 0).
Type Parameters
- TRandom
- The type of random number generator to create.
Return Value
TRandom[]An array of count RNG instances.
Remarks
This method creates streams using mixing-based hierarchical derivation (NumPy-style). Each stream is derived from the base seed material combined with its hierarchical path.
The startIndex parameter allows starting enumeration at a specific offset. For example, startIndex = 5 produces streams at positions [5], [6], [7], etc. relative to the prefix specified in options.
Stream creation is O(1) per stream in the number of streams at the same level, but O(depth) in the hierarchy depth due to path-based derivation.
Example
var options = new RandomOptions(42);
var streams = RandomStreams.CreateStreams<Pcg64>(10, in options, startIndex: 5);
// Produces streams at positions [5], [6], [7], ..., [14]Exceptions
| Argument | count is negative. |
CreateStreams<TRandom>(Int32, Int64, UInt64, SeedProfile)
public static TRandom[] CreateStreams<TRandom>(
int count,
long seed,
ulong startIndex = 0,
SeedProfile seedProfile = SeedProfile.Default
)
where TRandom : Object, IRandomSourceFactory<TRandom>
Parameters
- count Int32
- The number of generators to create (must be non-negative).
- seed Int64
- The base seed value.
- startIndex UInt64 (Optional)
- The starting index for stream enumeration (default is 0).
- seedProfile SeedProfile (Optional)
- The seed profile to use (default is Default).
Type Parameters
- TRandom
- The type of random number generator to create.
Return Value
TRandom[]An array of count RNG instances.
Remarks
This is a convenience overload that constructs RandomOptions from the provided seed and delegates to CreateStreams<TRandom>(Int32, RandomOptions, UInt64).
Example
var streams = RandomStreams.CreateStreams<Pcg64>(10, 42UL, startIndex: 5);Exceptions
| Argument | count is negative. |
CreateStreams<TRandom>(Int32, UInt64[], UInt64, SeedProfile)
public static TRandom[] CreateStreams<TRandom>(
int count,
ulong[] seedArray,
ulong startIndex = 0,
SeedProfile seedProfile = SeedProfile.Default
)
where TRandom : Object, IRandomSourceFactory<TRandom>
Parameters
- count Int32
- The number of generators to create (must be non-negative).
- seedArray UInt64[]
- The base seed array.
- startIndex UInt64 (Optional)
- The starting index for stream enumeration (default is 0).
- seedProfile SeedProfile (Optional)
- The seed profile to use (default is Default).
Type Parameters
- TRandom
- The type of random number generator to create.
Return Value
TRandom[]An array of count RNG instances.
Remarks
This is a convenience overload that constructs RandomOptions from the provided seed array and delegates to CreateStreams<TRandom>(Int32, RandomOptions, UInt64).
Example
var seedArray = new ulong[] { 42, 123, 456 };
var streams = RandomStreams.CreateStreams<Pcg64>(10, seedArray, startIndex: 5);Exceptions
| Argument | count is negative. |
| Argument | seedArray is null. |