Class EnumeratedDistribution.Sampler

java.lang.Object
org.apache.commons.math4.distribution.EnumeratedDistribution.Sampler
Enclosing class:
EnumeratedDistribution<T>

public class EnumeratedDistribution.Sampler
extends java.lang.Object
Sampler functionality.
  • Method Summary

    Modifier and Type Method Description
    T sample()
    Generates a random value sampled from this distribution.
    java.lang.Object[] sample​(int sampleSize)
    Generates a random sample from the distribution.
    T[] sample​(int sampleSize, T[] array)
    Generates a random sample from the distribution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • 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 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 - if sampleSize 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 - if sampleSize is not positive.
      NullArgumentException - if array is null