Class EnumeratedDistribution.Sampler
- java.lang.Object
-
- org.apache.commons.math4.legacy.distribution.EnumeratedDistribution.Sampler
-
- Enclosing class:
- EnumeratedDistribution<T>
public class EnumeratedDistribution.Sampler extends Object
Sampler functionality.-
The cumulative probability distribution is created (and sampled from)
using the input order of the
constructor arguments
: A different input order will create a different sequence of samples. The samples will only be reproducible with the same RNG starting from the same RNG state and the same input order to constructor. - The minimum supported probability is 2-53.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
sample()
Generates a random value sampled from this distribution.Object[]
sample(int sampleSize)
Generates a random sample from the distribution.T[]
sample(int sampleSize, T[] array)
Generates a random sample from the distribution.
-
-
-
Method Detail
-
sample
public T sample()
Generates a random value sampled from this distribution.- Returns:
- a random value.
-
sample
public Object[] sample(int sampleSize) throws NotStrictlyPositiveException
Generates a random sample from the distribution.- Parameters:
sampleSize
- the number of random values to generate.- Returns:
- an array representing the random sample.
- Throws:
NotStrictlyPositiveException
- ifsampleSize
is not positive.
-
sample
public T[] sample(int sampleSize, T[] array) throws NotStrictlyPositiveException
Generates a random sample from the distribution.If the requested samples fit in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.
- Parameters:
sampleSize
- the number of random values to generate.array
- the array to populate.- Returns:
- an array representing the random sample.
- Throws:
NotStrictlyPositiveException
- ifsampleSize
is not positive.NullArgumentException
- ifarray
is null
-
-