Class PoissonDistribution

java.lang.Object
org.apache.commons.statistics.distribution.AbstractDiscreteDistribution
org.apache.commons.statistics.distribution.PoissonDistribution
All Implemented Interfaces:
DiscreteDistribution

public final class PoissonDistribution extends AbstractDiscreteDistribution
Implementation of the Poisson distribution.

The probability mass function of \( X \) is:

\[ f(k; \lambda) = \frac{\lambda^k e^{-k}}{k!} \]

for \( \lambda \in (0, \infty) \) the mean and \( k \in \{0, 1, 2, \dots\} \) the number of events.

See Also:
  • Field Details

    • HALF_LOG_TWO_PI

      private static final double HALF_LOG_TWO_PI
      0.5 * ln(2 * pi). Computed to 25-digits precision.
      See Also:
    • MAX_MEAN

      private static final double MAX_MEAN
      Upper bound on the mean to use the PoissonSampler.
      See Also:
    • mean

      private final double mean
      Mean of the distribution.
  • Constructor Details

    • PoissonDistribution

      private PoissonDistribution(double mean)
      Parameters:
      mean - Poisson mean. probabilities.
  • Method Details

    • of

      public static PoissonDistribution of(double mean)
      Creates a Poisson distribution.
      Parameters:
      mean - Poisson mean.
      Returns:
      the distribution
      Throws:
      IllegalArgumentException - if mean <= 0.
    • probability

      public double probability(int x)
      For a random variable X whose values are distributed according to this distribution, this method returns P(X = x). In other words, this method represents the probability mass function (PMF) for the distribution.
      Parameters:
      x - Point at which the PMF is evaluated.
      Returns:
      the value of the probability mass function at x.
    • 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.
      Parameters:
      x - Point at which the PMF is evaluated.
      Returns:
      the logarithm of the value of the probability mass function at x.
    • cumulativeProbability

      public double cumulativeProbability(int x)
      For a random variable X whose values are distributed according to this distribution, this method returns P(X <= x). In other, words, this method represents the (cumulative) distribution function (CDF) for this distribution.
      Parameters:
      x - Point at which the CDF is evaluated.
      Returns:
      the probability that a random variable with this distribution takes a value less than or equal to x.
    • survivalProbability

      public double survivalProbability(int x)
      For a random variable X whose values are distributed according to this distribution, this method returns P(X > x). In other words, this method represents the complementary cumulative distribution function.

      By default, this is defined as 1 - cumulativeProbability(x), but the specific implementation may be more accurate.

      Parameters:
      x - Point at which the survival function is evaluated.
      Returns:
      the probability that a random variable with this distribution takes a value greater than x.
    • getMean

      public double getMean()
      Gets the mean of this distribution.
      Returns:
      the mean.
    • getVariance

      public double getVariance()
      Gets the variance of this distribution.

      The variance is equal to the mean.

      Returns:
      the variance.
    • getSupportLowerBound

      public int getSupportLowerBound()
      Gets the lower bound of the support. This method must return the same value as inverseCumulativeProbability(0), i.e. \( \inf \{ x \in \mathbb Z : P(X \le x) \gt 0 \} \). By convention, Integer.MIN_VALUE should be substituted for negative infinity.

      The lower bound of the support is always 0.

      Returns:
      0.
    • getSupportUpperBound

      public int getSupportUpperBound()
      Gets the upper bound of the support. This method must return the same value as inverseCumulativeProbability(1), i.e. \( \inf \{ x \in \mathbb Z : P(X \le x) = 1 \} \). By convention, Integer.MAX_VALUE should be substituted for positive infinity.

      The upper bound of the support is always positive infinity.

      Returns:
      Integer.MAX_VALUE
    • createSampler

      public DiscreteDistribution.Sampler createSampler(org.apache.commons.rng.UniformRandomProvider rng)
      Creates a sampler.
      Specified by:
      createSampler in interface DiscreteDistribution
      Overrides:
      createSampler in class AbstractDiscreteDistribution
      Parameters:
      rng - Generator of uniformly distributed numbers.
      Returns:
      a sampler that produces random numbers according this distribution.