Continuous Distribution.Sample Method
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
Overload List
| Sample() | Returns a single random sample drawn from this 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 a Random 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<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 convenience overload uses the thread-safe random source Instance to generate the uniform variate used by the sampling algorithm.
Successive calls produce independent samples that follow the probability law represented by this distribution.
Sample(Int32)
public Vector<double> Sample(
int size
)Parameters
- size Int32
- The number of samples to generate. Must be greater than zero.
Return Value
Vector<Double>A Vector<T> of length size.
Remarks
Exceptions
| Argument | size is less than or equal to zero. |
Sample(IRandomSource)
public double Sample(
IRandomSource random
)Parameters
- random IRandomSource
- A Random that will be adapted to the internal generator abstraction.
Return Value
DoubleA double-precision random variate.
Exceptions
| Argument | random is null. |
Sample<TGenerator>(IRandomSource<TGenerator>)
public double 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
DoubleA double-precision random variate.
Exceptions
| Argument | random is null. |
Sample(Random)
public double Sample(
Random random
)Parameters
Return Value
DoubleA double-precision random variate.
Exceptions
| Argument | random is null. |
Sample<TGenerator>(TGenerator)
protected virtual double 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
DoubleA double-precision 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<double> 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<Double>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<double> 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<Double>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<double> 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<Double>A Vector<T> containing size samples.
Remarks
Exceptions
| Argument | random is null. |
| Argument | size is less than or equal to zero. |