DiscreteDistribution.SampleInto Method

Definition

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

Overload List

SampleInto(Span<Int32>) Fills a span with random numbers from the distribution using the default thread-safe random number generator.
SampleInto(IRandomSource, IList<Int32>) Fills the provided list with random samples drawn from this distribution.
SampleInto(IRandomSource, Span<Int32>) Fills a span with random numbers from the distribution.
SampleInto(Random, IList<Int32>) Fills the provided list with random samples drawn from this distribution.
SampleInto(Random, Int32[]) Fills a list with random numbers from the distribution.
SampleInto(Random, Span<Int32>) Fills the given span with random samples drawn from this distribution.
SampleInto(IRandomSource, IList<Int32>, Int32, Int32) Fills a range within a list with random samples drawn from this distribution.
SampleInto(Random, IList<Int32>, Int32, Int32) Fills a range within a list with random samples drawn from this distribution.
SampleInto<TGenerator>(TGenerator, Span<Int32>) 
SampleInto<TGenerator>(IRandomSource<TGenerator>, Span<Int32>) Fills a span with random numbers from the distribution.
SampleInto<TGenerator>(TGenerator, IList<Int32>, Int32, Int32) Fills a range within a list with random samples drawn from this distribution.

SampleInto(Span<Int32>)

Fills a span with random numbers from the distribution using the default thread-safe random number generator.
C#
public void SampleInto(
	Span<int> samples
)

Parameters

samples  Span<Int32>
A Span<T>.

SampleInto<TGenerator>(TGenerator, Span<Int32>)

C#
protected void SampleInto<TGenerator>(
	ref TGenerator generator,
	Span<int> samples
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

generator  TGenerator
 
samples  Span<Int32>
 

Type Parameters

TGenerator

SampleInto(IRandomSource, IList<Int32>)

Fills the provided list with random samples drawn from this distribution.
C#
public void SampleInto(
	IRandomSource random,
	IList<int> samples
)

Parameters

random  IRandomSource
The Random used to produce uniform variates that are transformed to distribution samples.
samples  IList<Int32>
The destination list to receive generated samples. If samples is an array, this method routes to the span-based overload to avoid extra copying.

Exceptions

ArgumentNullExceptionThrown if samples is null.

SampleInto(IRandomSource, Span<Int32>)

Fills a span with random numbers from the distribution.
C#
public void SampleInto(
	IRandomSource random,
	Span<int> samples
)

Parameters

random  IRandomSource
An IRandomSource to use as the uniform random number generator.
samples  Span<Int32>
A Span<T>.

SampleInto<TGenerator>(IRandomSource<TGenerator>, Span<Int32>)

Fills a span with random numbers from the distribution.
C#
public void SampleInto<TGenerator>(
	IRandomSource<TGenerator> random,
	Span<int> samples
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

random  IRandomSource<TGenerator>
An IRandomSource<TGenerator> to use as the uniform random number generator.
samples  Span<Int32>
A Span<T>.

Type Parameters

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

SampleInto(Random, IList<Int32>)

Fills the provided list with random samples drawn from this distribution.
C#
public void SampleInto(
	Random random,
	IList<int> samples
)

Parameters

random  Random
The Random used to produce uniform variates that are transformed to distribution samples.
samples  IList<Int32>
The destination list to receive generated samples. If samples is an array, this method routes to the span-based overload to avoid extra copying.

Exceptions

ArgumentNullExceptionThrown if samples is null.

SampleInto(Random, Int32[])

Fills a list with random numbers from the distribution.
C#
public void SampleInto(
	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[]
An integer array.

Remarks

This method fills samples, with random samples from the distribution.

Exceptions

ArgumentNullException

samples is null.

-or-

random is null.

SampleInto(Random, Span<Int32>)

Fills the given span with random samples drawn from this distribution.
C#
public virtual void SampleInto(
	Random random,
	Span<int> samples
)

Parameters

random  Random
The Random used to produce uniform variates that are transformed into distribution samples.
samples  Span<Int32>
The destination span to write generated values into.

Remarks

The default implementation generates values by repeatedly calling Sample(Random). Derived classes may override this method to provide a more efficient bulk-sampling implementation.

Exceptions

ArgumentNullExceptionThrown when random is null.

SampleInto<TGenerator>(TGenerator, IList<Int32>, Int32, Int32)

Fills a range within a list with random samples drawn from this distribution.
C#
public virtual void SampleInto<TGenerator>(
	ref TGenerator generator,
	IList<int> samples,
	int startIndex,
	int length
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

generator  TGenerator
The random number generator used to generate uniform variates.
samples  IList<Int32>
The destination list to receive generated values.
startIndex  Int32
The zero-based index at which to begin writing.
length  Int32
The number of samples to write.

Type Parameters

TGenerator

Remarks

If samples is an array, this method forwards to the span-based implementation for better performance.

Exceptions

ArgumentNullException

samples is null.

ArgumentOutOfRangeExceptionThrown when startIndex or length is negative.
ArgumentExceptionThrown when the specified range (startIndex + length) exceeds the bounds of samples.

SampleInto(IRandomSource, IList<Int32>, Int32, Int32)

Fills a range within a list with random samples drawn from this distribution.
C#
public virtual void SampleInto(
	IRandomSource random,
	IList<int> samples,
	int startIndex,
	int length
)

Parameters

random  IRandomSource
The Random used to generate uniform variates.
samples  IList<Int32>
The destination list to receive generated values.
startIndex  Int32
The zero-based index at which to begin writing.
length  Int32
The number of samples to write.

Remarks

If samples is an array, this method forwards to the span-based implementation for better performance.

Exceptions

ArgumentNullExceptionThrown if samples or random is null.
ArgumentOutOfRangeExceptionThrown when startIndex or length is negative.
ArgumentExceptionThrown when the specified range (startIndex + length) exceeds the bounds of samples.

SampleInto(Random, IList<Int32>, Int32, Int32)

Fills a range within a list with random samples drawn from this distribution.
C#
public virtual void SampleInto(
	Random random,
	IList<int> samples,
	int startIndex,
	int length
)

Parameters

random  Random
The Random used to generate uniform variates.
samples  IList<Int32>
The destination list to receive generated values.
startIndex  Int32
The zero-based index at which to begin writing.
length  Int32
The number of samples to write.

Remarks

If samples is an array, this method forwards to the span-based implementation for better performance.

Exceptions

ArgumentNullExceptionThrown if samples or random is null.
ArgumentOutOfRangeExceptionThrown when startIndex or length is negative.
ArgumentExceptionThrown when the specified range (startIndex + length) exceeds the bounds of samples.

See Also