PoissonDistribution

Represents the Poisson distribution, defined by its average rate of occurrence.

The Poisson distribution models the number of events occurring in a fixed interval of time or space, assuming events happen independently and at a constant average rate. Classic examples include the number of emails received per hour, the number of typos on a page, or the number of customers arriving at a store in an hour. It is often used as an approximation to the binomial distribution when the number of trials is large and the probability of success is small. The support is the set of all non-negative integers {0, 1, 2, ...}.

The CDF and survival function use the regularized incomplete gamma function for numerical stability. Sampling uses Knuth's algorithm for small rates and a normal approximation for large rates.

Example:

val dist = PoissonDistribution(rate = 4.0)
dist.pmf(3) // 0.1954... (probability of exactly 3 events)
dist.cdf(3) // 0.4335... (probability of 3 or fewer events)
dist.quantileInt(0.5) // 4 (median)
dist.mean // 4.0
dist.variance // 4.0 (mean and variance are equal)

Constructors

Link copied to clipboard
constructor(rate: Double)

Properties

Link copied to clipboard
open override val entropy: Double

Returns the Shannon entropy of this Poisson distribution in nats.

Link copied to clipboard
open override val kurtosis: Double

The excess kurtosis of this distribution, equal to 1 / lambda. Always positive (leptokurtic).

Link copied to clipboard
open override val mean: Double

The mean of this distribution, equal to rate (lambda).

Link copied to clipboard

the average number of events per interval (lambda). Must be positive.

Link copied to clipboard
open override val skewness: Double

The skewness of this distribution, equal to 1 / sqrt(lambda). Always positive (right-skewed).

Link copied to clipboard
open override val variance: Double

The variance of this distribution, equal to rate (lambda). For the Poisson, mean and variance are equal.

Functions

Link copied to clipboard
open override fun cdf(k: Int): Double

Returns the cumulative distribution function value at k for this Poisson distribution.

Link copied to clipboard
open override fun logPmf(k: Int): Double

Returns the natural logarithm of the probability mass at k for this Poisson distribution.

Link copied to clipboard
open override fun pmf(k: Int): Double

Returns the probability mass at k for this Poisson distribution.

Link copied to clipboard
open override fun quantileInt(p: Double): Int

Returns the quantile (inverse CDF) for the given probability p as an integer.

Link copied to clipboard
open override fun sample(random: Random): Int

Draws a single random integer from this Poisson distribution.

Link copied to clipboard
open override fun sf(k: Int): Double

Returns the survival function value at k for this Poisson distribution.