Class EnumeratedDistribution.Sampler
- java.lang.Object
-
- org.apache.commons.math4.distribution.EnumeratedDistribution.Sampler
-
- Enclosing class:
- EnumeratedDistribution<T>
public class EnumeratedDistribution.Sampler extends java.lang.ObjectSampler functionality.
-
-
Method Detail
-
sample
public T sample()
Generates a random value sampled from this distribution.- Returns:
- a random value.
-
sample
public java.lang.Object[] sample(int sampleSize) throws NotStrictlyPositiveExceptionGenerates a random sample from the distribution.- Parameters:
sampleSize- the number of random values to generate.- Returns:
- an array representing the random sample.
- Throws:
NotStrictlyPositiveException- ifsampleSizeis 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- ifsampleSizeis not positive.NullArgumentException- ifarrayis null
-
-