Wrapped Random Source<TRng> Class
A Random adapter over a Numerics.NET random number generator.
Definition
Namespace: Numerics.NET.Random.Adapters
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public sealed class WrappedRandomSource<TRng> : Random
where TRng : class, IRandomSource
Type Parameters
- TRng
- The random source type, which must be a class implementing IRandomSource.
Remarks
WrappedRandomSource<TRng> enables usage of Numerics.NET RNGs in APIs that require Random. All random generation methods forward directly to the Underlying random source.
Interoperability Boundary:
This wrapper is strictly an interop adapter, not a performance mechanism:
- No caching guarantees: Repeated calls to AsRandom() may allocate new wrapper instances. Users should not rely on wrapper identity.
- No thread-safety improvements: Thread-safety behavior is entirely inherited from the underlying RNG.
- State preservation: The wrapper stores the RNG instance exactly (no copies, no cloning), so state mutations affect the original instance.
Round-tripping:
Calling AsRandomSource() on a WrappedRandomSource<TRng> returns the original Underlying instance, preserving identity.
Constructors
| Wrapped | Initializes a new instance of the WrappedRandomSource<TRng> class. |
Properties
| Bits | Gets the number of bits per word in the generator's native output. |
| Underlying | Gets the underlying Numerics.NET random number generator. |
Methods
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Get | Serves as the default hash function. (Inherited from Object) |
| Get | Creates a string filled with random hexadecimal characters. (Inherited from Random) |
| Get | Fills a buffer with random hexadecimal characters. (Inherited from Random) |
| Get | Creates an array populated with items chosen at random from the provided set of choices. (Inherited from Random) |
| Get | Creates an array populated with items chosen at random from the provided set of choices. (Inherited from Random) |
| Get | Fills the elements of a specified span with items chosen at random from the provided set of choices. (Inherited from Random) |
| Get | Creates a string populated with characters chosen at random from choices. (Inherited from Random) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Next() |
Returns a non-negative random integer.
(Overrides Random.Next()) |
| Next( |
Returns a non-negative random integer less than the specified maximum.
(Overrides Random.Next(Int32)) |
| Next( |
Returns a random integer within a specified range.
(Overrides Random.Next(Int32, Int32)) |
| Next |
Fills the elements of a specified array of bytes with random numbers.
(Overrides Random.NextBytes(Byte[])) |
| Next |
Fills the elements of a specified span of bytes with random numbers.
(Overrides Random.NextBytes(Span<Byte>)) |
| Next |
Returns a random floating-point number in the range [0.0, 1.0).
(Overrides Random.NextDouble()) |
| Next |
Returns a non-negative random 64-bit integer.
(Overrides Random.NextInt64()) |
| Next |
Returns a non-negative random 64-bit integer less than the specified maximum.
(Overrides Random.NextInt64(Int64)) |
| Next |
Returns a random 64-bit integer within a specified range.
(Overrides Random.NextInt64(Int64, Int64)) |
| Next |
Returns a random single-precision floating-point number in the range [0.0, 1.0).
(Overrides Random.NextSingle()) |
| Next | Returns a random 32-bit unsigned integer. |
| Next | Returns a random 64-bit unsigned integer. |
| Shuffle<T>(T[]) | Performs an in-place shuffle of an array. (Inherited from Random) |
| Shuffle<T>(Span<T>) | Performs an in-place shuffle of a span. (Inherited from Random) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |
Extension Methods
| AsRandom |
Converts a Random to a random source.
(Defined by RandomInteropExtensions) |
| Correlated |
Generates a series of random variables with the specified correlation matrix.
(Defined by RandomSamplingExtensions) |
| Fill |
Fills a Double array with random numbers.
(Defined by RandomExtensions) |
| Fill |
Fills an Int32 array with random numbers.
(Defined by RandomExtensions) |
| 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 a vector with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions) |
| Fill |
Fills a Double array with random numbers.
(Defined by RandomExtensions) |
| Fill |
Fills an Int32 array with random numbers.
(Defined by RandomExtensions) |
| Fill |
Fills part of an array with random samples from the specified continuous distribution.
(Defined by RandomExtensions) |
| Fill |
Fills part of an array with random samples from the specified discrete distribution.
(Defined by RandomExtensions) |
| Fill |
Fills a list with normal random numbers with zero mean and unit
standard deviation.
(Defined by RandomExtensions) |
| Fill |
Fills a list with normal random numbers with zero mean and unit
standard deviation.
(Defined by RandomExtensions) |
| Fill |
Populates the specified span with numbers chosen at random
between 0 and the provided count without replacement.
(Defined by RandomExtensions) |
| Get |
Creates an array populated with items chosen at random
from the provided set of choices without replacement.
(Defined by RandomExtensions) |
| Get |
Populates the specified span with items chosen at random
from the provided set of choices without replacement.
(Defined by RandomExtensions) |
| Get |
Creates an array populated with items chosen at random
from the provided set of choices without replacement.
(Defined by RandomExtensions) |
| Next |
Generates a random sample from the specified discrete distribution.
(Defined by RandomSamplingExtensions) |
| 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 |
Generates a random sample from the specified continuous distribution.
(Defined by RandomSamplingExtensions) |
| Next |
Returns a random 64-bit integer.
(Defined by RandomExtensions) |
| Next |
Returns a random unsigned integer less than the specified value.
(Defined by RandomExtensions) |
| Next |
Returns a random 64-bit integer.
(Defined by RandomExtensions) |
| Next |
Returns a non-negative random integer that is less than the specified maximum.
(Defined by RandomExtensions) |
| Try |
Attempts to unwrap a Random to recover the underlying
random source.
(Defined by RandomInteropExtensions) |
| Try |
Attempts to unwrap a Random to recover the underlying
random source with the exact specified type.
(Defined by RandomInteropExtensions) |