DiscreteDistribution<T>.Sample Method

Definition

Namespace: Numerics.NET.Statistics.Distributions
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.2

Overload List

Sample() Returns a random sample from the distribution.
Sample(Int32) Returns a vector of random samples from the distribution.
Sample(Random) Returns a random sample from the distribution.
Sample(Int32, Random) Returns a vector of random samples from the distribution.
Sample(Random, T[]) Fills an array with random samples.
Sample(Random, T[], Int32, Int32) Fills an array with random samples from this DiscreteDistribution<T>.

Sample

Returns a random sample from the distribution.
C#
public T Sample()

Return Value

T
A sample from the distribution.

Remarks

This method uses the default random number generator specified by DefaultRandomNumberGenerator 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)

Returns a vector of random samples from the distribution.
C#
public CategoricalVector<T> Sample(
	int count
)

Parameters

count  Int32
The number of samples to return.

Return Value

CategoricalVector<T>
A categorical vector of samples.

Remarks

This method uses the default random number generator specified by DefaultRandomNumberGenerator to generate random samples from the distribution. The return value contains a set of values that follow the statistical distribution represented by this distribution.

Sample(Random)

Returns a random sample from the distribution.
C#
public T Sample(
	Random random
)

Parameters

random  Random
A Random object that specifies the uniform random number generator that is to be used to generate the samples.

Return Value

T
A sample 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 statistical distribution represented by this distribution.

Sample(Int32, Random)

Returns a vector of random samples from the distribution.
C#
public CategoricalVector<T> Sample(
	int count,
	Random random
)

Parameters

count  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

CategoricalVector<T>
A categorical vector of samples.

Remarks

This method uses the random number generator specified by random to generate a random sample from the distribution. The return value contains a set of values that follow the statistical distribution represented by this distribution.

Sample(Random, T[])

Fills an array with random samples.
C#
public void Sample(
	Random random,
	T[] samples
)

Parameters

random  Random
A Random object that specifies the uniform random number generator that is to be used to generate the samples.
samples  T[]
An array of integers.

Remarks

This method fills the integer array samples with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

-or-

samples is null.

Sample(Random, T[], Int32, Int32)

Fills an array with random samples from this DiscreteDistribution<T>.
C#
public void Sample(
	Random random,
	T[] samples,
	int startIndex,
	int length
)

Parameters

random  Random
A Random object that specifies the uniform random number generator that is to be used to generate the samples.
samples  T[]
An 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

ArgumentNullException

samples is null.

-or-

random is null.

ArgumentOutOfRangeException

startIndex is less than zero.

-or-

length is less than zero.

ArgumentException

length is greater than the number of elements from startIndex to the end of samples.

See Also