DiscreteDistribution<T>.Sample Method

Definition

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

Overload List

Sample() Returns a random sample from the distribution.
Sample(Int32) Returns a vector of random samples from the distribution.
Sample(IRandomSource) Returns the level index of a random sample 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(IRandomSource, Span<T>) Fills a span with random samples from this DiscreteDistribution<T>.
Sample(Random, T[]) Fills a span with random samples from this DiscreteDistribution<T>.
Sample(Random, Span<T>) Fills a span with random samples from this DiscreteDistribution<T>.
Sample(Random, T[], Int32, Int32) Fills a span with random samples from this DiscreteDistribution<T>.
Sample<TGenerator>(IRandomSource<TGenerator>) 
Sample<TGenerator>(Int32, IRandomSource<TGenerator>) Returns a vector of random samples from the distribution.
Sample<TGenerator>(IRandomSource<TGenerator>, Span<T>) Fills a span with random samples from this DiscreteDistribution<T>.
Sample<TGenerator>(TGenerator, Span<T>) Fills a span 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(IRandomSource)

Returns the level index of a random sample from the distribution.
C#
public T Sample(
	IRandomSource random
)

Parameters

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

Return Value

T
The index of the sample in the set of items.

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<TGenerator>(IRandomSource<TGenerator>)

C#
public T Sample<TGenerator>(
	IRandomSource<TGenerator> random
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

random  IRandomSource<TGenerator>
 

Type Parameters

TGenerator

Return Value

T

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<TGenerator>(Int32, IRandomSource<TGenerator>)

Returns a vector of random samples from the distribution.
C#
public CategoricalVector<T> Sample<TGenerator>(
	int count,
	IRandomSource<TGenerator> random
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

count  Int32
The number of samples to return.
random  IRandomSource<TGenerator>
A Random object that specifies the uniform random number generator that is to be used to generate the samples.

Type Parameters

TGenerator
The underlying generator type of the random source, used to enable optimizations like inlining.

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(IRandomSource, Span<T>)

Fills a span with random samples from this DiscreteDistribution<T>.
C#
public void Sample(
	IRandomSource random,
	Span<T> samples
)

Parameters

random  IRandomSource
A Random object that specifies the uniform random number generator that is to be used to generate the samples.
samples  Span<T>
A span.

Remarks

This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

Sample<TGenerator>(IRandomSource<TGenerator>, Span<T>)

Fills a span with random samples from this DiscreteDistribution<T>.
C#
public void Sample<TGenerator>(
	IRandomSource<TGenerator> random,
	Span<T> samples
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

random  IRandomSource<TGenerator>
A Random object that specifies the uniform random number generator that is to be used to generate the samples.
samples  Span<T>
A span.

Type Parameters

TGenerator
The underlying generator type of the random source, used to enable optimizations like inlining.

Remarks

This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

Sample(Random, T[])

Fills a span with random samples from this DiscreteDistribution<T>.
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[]
A span.

Remarks

This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

Sample(Random, Span<T>)

Fills a span with random samples from this DiscreteDistribution<T>.
C#
public void Sample(
	Random random,
	Span<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  Span<T>
A span.

Remarks

This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

Sample<TGenerator>(TGenerator, Span<T>)

Fills a span with random samples from this DiscreteDistribution<T>.
C#
public void Sample<TGenerator>(
	ref TGenerator generator,
	Span<T> samples
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

generator  TGenerator
 
samples  Span<T>
A span.

Type Parameters

TGenerator
The underlying generator type of the random source, used to enable optimizations like inlining.

Remarks

This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

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

Fills a span 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[]
A span.
startIndex  Int32
 
length  Int32
 

Remarks

This method fills a block of length elements of samples, starting at index startIndex with random samples from the distribution.

Exceptions

ArgumentNullException

random is null.

See Also