Class AbstractIntegerDistribution

    • Constructor Detail

      • AbstractIntegerDistribution

        public AbstractIntegerDistribution()
    • Method Detail

      • probability

        public double probability​(int x0,
                                  int x1)
                           throws NumberIsTooLargeException
        For a random variable X whose values are distributed according to this distribution, this method returns P(x0 < X <= x1). The default implementation uses the identity

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

        Specified by:
        probability in interface DiscreteDistribution
        Parameters:
        x0 - Lower bound (exclusive).
        x1 - Upper bound (inclusive).
        Returns:
        the probability that a random variable with this distribution will take a value between x0 and x1, excluding the lower and including the upper endpoint.
        Throws:
        NumberIsTooLargeException
        Since:
        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}.
        Parameters:
        p - the cumulative probability
        lower - a value satisfying cumulativeProbability(lower) < p
        upper - a value satisfying p <= cumulativeProbability(upper)
        Returns:
        the smallest p-quantile of this distribution
      • logProbability

        public double logProbability​(int x)
        For a random variable X whose values are distributed according to this distribution, this method returns log(P(X = x)), where log is the natural logarithm.

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

        Specified by:
        logProbability in interface DiscreteDistribution
        Parameters:
        x - Point at which the PMF is evaluated.
        Returns:
        the logarithm of the value of the probability mass function at x.
      • sample

        public static int[] sample​(int n,
                                   DiscreteDistribution.Sampler sampler)
        Utility function for allocating an array and filling it with n samples generated by the given sampler.
        Parameters:
        n - Number of samples.
        sampler - Sampler.
        Returns:
        an array of size n.