Class 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 Detail

      • sample

        public T sample()
        Generates a random value sampled from this distribution.
        Returns:
        a random value.
      • 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 - if sampleSize is not positive.
        NullArgumentException - if array is null