Class AbstractIntegerDistribution

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public abstract class AbstractIntegerDistribution
    extends Object
    implements org.apache.commons.statistics.distribution.DiscreteDistribution
    Base class for integer-valued discrete distributions. Default implementations are provided for some of the methods that do not vary from distribution to distribution.
    • Method Detail

      • probability

        public double probability​(int x0,
                                  int x1)
                           throws NumberIsTooLargeException
        The default implementation uses the identity

        P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)

        Specified by:
        probability in interface org.apache.commons.statistics.distribution.DiscreteDistribution
        4.0, was previously named cumulativeProbability
      • solveInverseCumulativeProbability

        protected int solveInverseCumulativeProbability​(double p,
                                                        int lower,
                                                        int upper)
        This is a utility function used by inverseCumulativeProbability(double). It assumes 0 < p < 1 and that the inverse cumulative probability lies in the bracket (lower, upper]. The implementation does simple bisection to find the smallest p-quantile inf{x in Z | P(X<=x) >= p}.
        p - the cumulative probability
        lower - a value satisfying cumulativeProbability(lower) < p
        upper - a value satisfying p <= cumulativeProbability(upper)
        the smallest p-quantile of this distribution
      • logProbability

        public double logProbability​(int x)

        The default implementation simply computes the logarithm of probability(x).

        Specified by:
        logProbability in interface org.apache.commons.statistics.distribution.DiscreteDistribution
      • sample

        public static int[] sample​(int n,
                                   org.apache.commons.statistics.distribution.DiscreteDistribution.Sampler sampler)
        Utility function for allocating an array and filling it with n samples generated by the given sampler.
        n - Number of samples.
        sampler - Sampler.
        an array of size n.
      • createSampler

        public org.apache.commons.statistics.distribution.DiscreteDistribution.Sampler createSampler​(org.apache.commons.rng.UniformRandomProvider rng)
        Specified by:
        createSampler in interface org.apache.commons.statistics.distribution.DiscreteDistribution