Count probabilities
Estimating the likelihood of observing a specified number of events when the expected count is known.
SciPy · Function
scipy.stats.poisson represents a Poisson discrete random variable. Provide a nonnegative mu and use its distribution methods to evaluate probabilities, compute statistics, or generate random counts.
poisson is a discrete random-variable object for Poisson counts. Supply the nonnegative shape parameter mu to methods such as pmf, cdf, and rvs; use loc when the distribution should be shifted.
scipy.stats.poisson = <scipy.stats._discrete_distns.poisson_gen object>| Name | Type | Description |
|---|---|---|
k | array_like | Quantile or count at which a distribution method is evaluated. |
mu | array_like | Nonnegative Poisson shape parameter. |
loc | array_like, optional | Location parameter used to shift the distribution. |
A Poisson distribution object exposing inherited discrete-distribution methods and Poisson-specific behavior.
rv_discrete.mu as the distribution's shape parameter, with zero allowed.loc argument translates the distribution's support.loc from the queried count.mu must be nonnegative; negative values do not define this distribution.loc for a shifted support instead of modifying the count passed to every method.from scipy.stats import poisson
mu = 3
k = 4
print(poisson.pmf(k, mu))
print(poisson.cdf(k, mu))
print(poisson.rvs(mu, size=5, random_state=0))Computes the probability and cumulative probability for four events, then draws five reproducible random variates from a Poisson distribution with mean 3.
Estimating the likelihood of observing a specified number of events when the expected count is known.
Generating synthetic event-count data for simulations or tests.
Modeling counts whose support needs to be translated by a fixed integer offset.
scipy.stats.poisson represent, and what constraint applies to mu?poisson represents a Poisson discrete random variable, and its probability mass function is \(f(k)=\exp(-\mu)\mu^k/k!\) for nonnegative integer counts. The shape parameter mu must satisfy \(\mu\geq0\).
Follow-up: How would you shift the count values? Pass loc; the documentation states that shifting changes the distribution's location.
Call methods such as poisson.pmf(k, mu) for a point probability and poisson.cdf(k, mu) for a cumulative probability. The object inherits generic methods from rv_discrete and adds the Poisson-specific definition.
Follow-up: How can the same distribution be reused with fixed parameters? Create a frozen object with poisson(mu, loc=...), then call its methods without resupplying those parameters.
loc parameter?loc shifts the distribution. For the PMF, poisson.pmf(k, mu, loc) is equivalent to evaluating the unshifted distribution at k - loc.
Follow-up: What happens when mu is zero? The PMF returns 1.0 at k=0, making the distribution concentrated at zero before any location shift.
scipy.stats.rv_discretescipy.stats.poisson.pmfscipy.stats.poisson.cdfscipy.stats.poisson.rvs