DiscreteDistribution.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, Int32[]) Fills an Int32 array with random numbers.
Sample(Random, Int32[], Int32, Int32) Fills an Int32 array with random numbers from this DiscreteDistribution.

Sample

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

Return Value

Int32
A signed 32-bit integer.

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 Vector<int> Sample(
	int count
)

Parameters

count  Int32
The number of samples to return.

Return Value

Vector<Int32>
A signed 32-bit integer.

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 virtual int 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

Int32
A signed 32-bit integer.

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 Vector<int> 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

Vector<Int32>
A vector of signed 32-bit integers.

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, Int32[])

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

Parameters

random  Random
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

ArgumentNullException

random is null.

-or-

samples is null.

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

Fills an Int32 array with random numbers from this DiscreteDistribution.
C#
public virtual void Sample(
	Random random,
	int[] 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  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

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