Class PoissonDistribution
java.lang.Object
org.apache.commons.statistics.distribution.AbstractDiscreteDistribution
org.apache.commons.statistics.distribution.PoissonDistribution
- All Implemented Interfaces:
DiscreteDistribution
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface DiscreteDistribution
DiscreteDistribution.Sampler -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateSampler(org.apache.commons.rng.UniformRandomProvider rng) Creates a sampler.doublecumulativeProbability(int x) For a random variableXwhose values are distributed according to this distribution, this method returnsP(X <= x).doublegetMean()Gets the mean of this distribution.intGets the lower bound of the support.intGets the upper bound of the support.doubleGets the variance of this distribution.doublelogProbability(int x) For a random variableXwhose values are distributed according to this distribution, this method returnslog(P(X = x)), wherelogis the natural logarithm.static PoissonDistributionof(double mean) Creates a Poisson distribution.doubleprobability(int x) For a random variableXwhose values are distributed according to this distribution, this method returnsP(X = x).doublesurvivalProbability(int x) For a random variableXwhose values are distributed according to this distribution, this method returnsP(X > x).Methods inherited from class AbstractDiscreteDistribution
getMedian, inverseCumulativeProbability, inverseSurvivalProbability, probability
-
Field Details
-
MAX_MEAN
private static final double MAX_MEANUpper bound on the mean to use the PoissonSampler.- See Also:
-
mean
private final double meanMean of the distribution.
-
-
Constructor Details
-
PoissonDistribution
private PoissonDistribution(double mean) - Parameters:
mean- Poisson mean. probabilities.
-
-
Method Details
-
of
Creates a Poisson distribution.- Parameters:
mean- Poisson mean.- Returns:
- the distribution
- Throws:
IllegalArgumentException- ifmean <= 0.
-
probability
public double probability(int x) For a random variableXwhose values are distributed according to this distribution, this method returnsP(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 variableXwhose values are distributed according to this distribution, this method returnslog(P(X = x)), wherelogis 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 variableXwhose values are distributed according to this distribution, this method returnsP(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 variableXwhose values are distributed according to this distribution, this method returnsP(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 asinverseCumulativeProbability(0), i.e. \( \inf \{ x \in \mathbb Z : P(X \le x) \gt 0 \} \). By convention,Integer.MIN_VALUEshould 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 asinverseCumulativeProbability(1), i.e. \( \inf \{ x \in \mathbb Z : P(X \le x) = 1 \} \). By convention,Integer.MAX_VALUEshould be substituted for positive infinity.The upper bound of the support is always positive infinity.
- Returns:
Integer.MAX_VALUE
-
createSampler
Creates a sampler.- Specified by:
createSamplerin interfaceDiscreteDistribution- Overrides:
createSamplerin classAbstractDiscreteDistribution- Parameters:
rng- Generator of uniformly distributed numbers.- Returns:
- a sampler that produces random numbers according this distribution.
-