Lesson 17 of 18

Poisson Distribution

The Poisson Distribution

The Poisson distribution models the number of events occurring in a fixed interval of time or space, when events happen independently at a constant average rate λ\lambda.

PMF

The probability of observing exactly kk events:

P(X=k)=eλλkk!k=0,1,2,P(X = k) = \frac{e^{-\lambda} \lambda^k}{k!} \quad k = 0, 1, 2, \ldots

  • Mean: E[X]=λE[X] = \lambda
  • Variance: Var(X)=λ\text{Var}(X) = \lambda

Real-World Examples

Scenarioλ\lambda
Calls to a call centre per houre.g. 10
Mutations per DNA strande.g. 0.001
Accidents on a road per monthe.g. 2
Emails received per minutee.g. 3

Examples

For λ=1\lambda = 1: P(X=0)=e10.3679P(X=1)=e10.3679P(X=0) = e^{-1} \approx 0.3679 \qquad P(X=1) = e^{-1} \approx 0.3679

For λ=3\lambda = 3: P(X=3)=e32760.2240P(X=3) = \frac{e^{-3} \cdot 27}{6} \approx 0.2240

Implementation

import math

def poisson_pmf(lam, k):
    return round(math.exp(-lam) * lam**k / math.factorial(k), 4)

Relationship to Binomial

When nn is large and pp is small with np=λnp = \lambda, the binomial distribution B(n,p)B(n,p) approaches Poisson(λ)( \lambda). This is why Poisson appears in rare-event scenarios.

Your Task

Implement poisson_pmf(lam, k) that returns P(X=k)P(X=k) for a Poisson distribution with rate λ\lambda, rounded to 4 decimal places.

Pyodide loading...
Loading...
Click "Run" to execute your code.