IRandom Source Interface
Represents a modern random number generator with a consistent API surface.
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 interface IRandomSource : IStateful- Implements
- IStateful
Remarks
IRandomSource defines the high-level API for random number generation that is expected by Numerics.NET's algorithms and distributions. It provides:
- Standard integer generation: Next(), Next(Int32), Next(Int32, Int32)
- 64-bit integer generation: NextInt64(), NextInt64(Int64), NextInt64(Int64, Int64)
- Floating-point generation: NextDouble(), NextSingle()
- Byte buffer filling: NextBytes(Byte[]), NextBytes(Span<Byte>)
- Primitive unsigned generation: NextUInt32(), NextUInt64()
Metadata:
Implementations must provide metadata describing the generator's characteristics:
- Name: A human-readable name for the generator (e.g., "Pcg64", "Xoshiro256**")
- BitsPerWord: The native word size (32 or 64) of the underlying generator
Usage in Numerics.NET:
Higher-level Numerics.NET APIs accept IRandomSource when they need a general-purpose RNG abstraction. For performance-critical hot paths, prefer IRandomSource<TGenerator> which provides typed access to the underlying Layer 2 generator for zero-overhead operation.
Properties
| Bits | Gets the number of bits per word in the generator's native output. |
| Name | Gets a human-readable name for this random number generator. |
| State |
Gets the number of bytes required to save/load this engine's state.
(Inherited from IStateful) |
Methods
| Fill( | Fills a span with random double-precision floating-point numbers in [0, 1). |
| Fill( | Fills a span with random single-precision floating-point numbers in [0, 1). |
| Fill( | Fills a span with random 32-bit unsigned integer values. |
| Fill( | Fills a span with random 64-bit unsigned integer values. |
| Load |
Loads the engine's state from the source span in a stable little-endian format.
(Inherited from IStateful) |
| Next() | Returns a non-negative random integer. |
| Next( | Returns a non-negative random integer less than the specified maximum. |
| Next( | Returns a random integer within a specified range. |
| Next | Fills the elements of a specified array of bytes with random numbers. |
| Next | Fills the elements of a specified span of bytes with random numbers. |
| Next | Returns a random floating-point number in the range [0.0, 1.0). |
| Next | Returns a non-negative random 64-bit integer. |
| Next | Returns a non-negative random 64-bit integer less than the specified maximum. |
| Next | Returns a random 64-bit integer within a specified range. |
| Next | Returns a random single-precision floating-point number in the range [0.0, 1.0). |
| Next | Returns a random 32-bit unsigned integer. |
| Next | Returns a random 64-bit unsigned integer. |
| Save |
Saves the engine's state to the destination span in a stable little-endian format.
(Inherited from IStateful) |
Extension Methods
| AsRandom |
Converts a random source to a Random.
(Defined by RandomInteropExtensions) |
| Correlated |
Generates a series of random variables with the specified correlation matrix.
(Defined by RandomSamplingExtensions) |
| Fill |
Fills the elements of a specified span with random double-precision floating-point numbers.
(Defined by RandomSourceExtensions) |
| Fill |
Fills the elements of a specified span with random double-precision floating-point numbers.
(Defined by RandomSourceExtensions) |
| Fill |
Fills the elements of a specified span with random single-precision floating-point numbers.
(Defined by RandomSourceExtensions) |
| Fill |
Fills the elements of a specified span with random 32-bit signed integers.
(Defined by RandomSourceExtensions) |
| Fill |
Fills the elements of a specified span with random 64-bit signed integers.
(Defined by RandomSourceExtensions) |
| Fill |
Fills a span with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions) |
| Fill |
Fills a span with random samples from the specified discrete distribution.
(Defined by RandomSamplingExtensions) |
| Fill |
Fills the elements of a specified span with random 32-bit signed integers less than the specified maximum.
(Defined by RandomSourceExtensions) |
| Fill |
Fills the elements of a specified span with random 64-bit signed integers less than the specified maximum.
(Defined by RandomSourceExtensions) |
| Fill |
Fills a vector with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions) |
| Fill |
Fills the elements of a specified span with random 32-bit signed integers within a specified range.
(Defined by RandomSourceExtensions) |
| Fill |
Fills the elements of a specified span with random 64-bit signed integers within a specified range.
(Defined by RandomSourceExtensions) |
| Fill |
Populates the specified span with numbers chosen at random
between 0 and the provided count without replacement.
(Defined by RandomSourceExtensions) |
| Next |
Returns a non-negative random integer.
(Defined by RandomSourceExtensions) |
| Next |
Generates a random sample from the specified continuous distribution.
(Defined by RandomSamplingExtensions) |
| Next |
Generates a random sample from the specified discrete distribution.
(Defined by RandomSamplingExtensions) |
| Next |
Returns a non-negative random integer that is less than the specified maximum.
(Defined by RandomSourceExtensions) |
| Next |
Generates an array of random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions) |
| Next |
Generates an array of random samples from the specified discrete distribution.
(Defined by RandomSamplingExtensions) |
| Next |
Returns a random integer that is within a specified range.
(Defined by RandomSourceExtensions) |
| Next |
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Defined by RandomSourceExtensions) |
| Next |
Returns a non-negative random 32-bit integer.
(Defined by RandomSourceExtensions) |
| Next |
Returns a non-negative random 64-bit integer.
(Defined by RandomSourceExtensions) |
| Next |
Returns a non-negative random 64-bit integer that is less than the specified maximum.
(Defined by RandomSourceExtensions) |
| Next |
Returns a random 64-bit integer that is within a specified range.
(Defined by RandomSourceExtensions) |
| Next |
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Defined by RandomSourceExtensions) |
| Shuffle<T> |
Shuffles the elements of an IList<T> in place
using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions) |
| Shuffle<T> |
Shuffles the elements of an array in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions) |
| Shuffle<T> |
Shuffles the elements of a span in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions) |