Discrete Distribution.Sample Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
Overload List
| Sample() | Returns a random sample from the distribution. |
| Sample( | Returns a vector containing the specified number of independent random samples drawn from this distribution. |
| Sample( | Returns a random sample from the distribution using an IRandomSource instance. |
| Sample( | Returns a random sample from the distribution using a Random instance. |
| Sample( | Returns a vector containing the specified number of independent random samples drawn from this distribution using the provided IRandomSource. |
| Sample( | Returns a vector of random samples from the distribution. |
| Sample( |
Fills an Int32 array with random numbers.
|
| Sample( |
Fills an Int32 array with random numbers.
|
| Sample( |
Fills an Int32 array with random numbers from this DiscreteDistribution.
|
| Sample( |
Fills an Int32 array with random numbers from this DiscreteDistribution.
|
| Sample<TGenerator>(IRandomSource<TGenerator>) | Returns a random sample from the distribution using the supplied IRandomSource<TGenerator>. |
| Sample<TGenerator>(TGenerator) | Returns a random sample from the distribution using the provided generator. |
| Sample<TGenerator>(Int32, IRandomSource<TGenerator>) | Returns a vector containing the specified number of independent random samples drawn from this distribution using the supplied IRandomSource<TGenerator>. |
Sample
Remarks
This method uses the default random number generator specified by Instance to generate a random sample from the distribution. The return values of successive calls to this method follow the statistical distribution represented by this distribution.
Sample(Int32)
public Vector<int> Sample(
int size
)Parameters
- size Int32
- The number of samples to generate. Must be greater than zero.
Return Value
Vector<Int32>A Vector<T> of length size.
Remarks
Exceptions
| Argument | size is less than or equal to zero. |
Sample(IRandomSource)
public int Sample(
IRandomSource random
)Parameters
- random IRandomSource
- An IRandomSource that will be adapted to the internal generator abstraction.
Return Value
Int32A signed 32-bit integer random variate.
Exceptions
| Argument | random is null. |
Sample<TGenerator>(IRandomSource<TGenerator>)
public int Sample<TGenerator>(
IRandomSource<TGenerator> random
)
where TGenerator : struct, new(), IRandomGenerator
Parameters
- random IRandomSource<TGenerator>
- The random source that exposes a IRandomGenerator used to produce uniform variates.
Type Parameters
- TGenerator
- The underlying generator type of the random source, used to enable optimizations like inlining.
Return Value
Int32A signed 32-bit integer random variate.
Exceptions
| Argument | random is null. |
Sample(Random)
public int Sample(
Random random
)Parameters
Return Value
Int32A signed 32-bit integer random variate.
Exceptions
| Argument | random is null. |
Sample<TGenerator>(TGenerator)
protected virtual int Sample<TGenerator>(
ref TGenerator generator
)
where TGenerator : struct, new(), IRandomGenerator
Parameters
- generator TGenerator
- A reference to a struct implementing IRandomGenerator used to produce uniform variates.
Type Parameters
- TGenerator
- The underlying generator type of the random source, used to enable optimizations like inlining.
Return Value
Int32A signed 32-bit integer random variate.
Remarks
Implementations may override this method to provide a more efficient or specialized sampling algorithm that consumes raw uniform variates from generator.
Sample(Int32, IRandomSource)
public Vector<int> Sample(
int size,
IRandomSource random
)Parameters
- size Int32
- The number of samples to generate. Must be greater than zero.
- random IRandomSource
- The random source to use for generating uniform variates.
Return Value
Vector<Int32>A Vector<T> of length size.
Remarks
Exceptions
| Argument | random is null. |
| Argument | size is less than or equal to zero. |
Sample(Int32, Random)
public Vector<int> Sample(
int size,
Random random
)Parameters
- size Int32
- The number of samples to return.
- random Random
- A Random object that specifies the uniform random number generator that is to be used to generate the samples.
Return Value
Vector<Int32>A vector of size samples from the distribution.
Remarks
This method uses the random number generator specified by random to generate a random sample from the distribution. The return values of successive calls to this method follow the distribution represented by this Distribution.
Exceptions
| Argument | random is null. |
| Argument | size is less than zero. |
Sample<TGenerator>(Int32, IRandomSource<TGenerator>)
public Vector<int> Sample<TGenerator>(
int size,
IRandomSource<TGenerator> random
)
where TGenerator : struct, new(), IRandomGenerator
Parameters
- size Int32
- The number of samples to generate. Must be greater than zero.
- random IRandomSource<TGenerator>
- The random source that exposes a TGenerator generator.
Type Parameters
- TGenerator
- The underlying generator type of the random source, used to enable optimizations like inlining.
Return Value
Vector<Int32>A Vector<T> containing size samples.
Remarks
Exceptions
| Argument | random is null. |
| Argument | size is less than or equal to zero. |
Sample(IRandomSource, Int32[])
[ObsoleteAttribute("Use the SampleInto method with Span<int> instead.")]
public void Sample(
IRandomSource random,
int[] samples
)Parameters
- random IRandomSource
- A Random object that specifies the uniform random number generator that is to be used to generate the samples.
- samples Int32[]
- A Int32 array.
Remarks
This method fills the integer array samples with random samples from the distribution.
Exceptions
| Argument | random is null. -or- samples is null. |
Sample(Random, Int32[])
[ObsoleteAttribute("Use the SampleInto method with Span<int> instead.")]
public void Sample(
Random random,
int[] samples
)Parameters
Remarks
This method fills the integer array samples with random samples from the distribution.
Exceptions
| Argument | random is null. -or- samples is null. |
Sample(IRandomSource, Int32[], Int32, Int32)
[ObsoleteAttribute("Use the SampleInto method with Span<int> instead.")]
public void Sample(
IRandomSource random,
int[] samples,
int startIndex,
int length
)Parameters
- random IRandomSource
- A IRandomSource object that specifies the uniform random number generator that is to be used to generate the samples.
- samples Int32[]
- A Int32 array.
- startIndex Int32
- The zero-based index at which to begin filling the samples array.
- length Int32
- The number of samples to provide.
Remarks
This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.
Exceptions
| Argument | samples is null. -or- random is null. |
| Argument | startIndex is less than zero. -or- length is less than zero. |
| Argument | length is greater than the number of elements from startIndex to the end of samples. |
Sample(Random, Int32[], Int32, Int32)
[ObsoleteAttribute("Use the SampleInto method with Span<int> instead.")]
public void Sample(
Random random,
int[] samples,
int startIndex,
int length
)Parameters
Remarks
This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.
Exceptions
| Argument | samples is null. -or- random is null. |
| Argument | startIndex is less than zero. -or- length is less than zero. |
| Argument | length is greater than the number of elements from startIndex to the end of samples. |