TExcelTAD
Home › NumPy › Poisson Distribution

Poisson Distribution

The Poisson distribution counts how many times an event happens in a fixed interval of time or space, when events occur independently at a known average rate. Examples: calls to a help desk per hour, typos per page, meteors per minute during a shower, customers arriving per 5 minutes.

Like the binomial, it is discrete: results are whole numbers 0, 1, 2, …. Unlike the binomial, there is no upper limit.

Parameter Meaning
lam λ (lambda): the average number of events per interval
size output shape

Generating Poisson data

python · try it yourself
import numpy as np

rng = np.random.default_rng(42)
# A café gets 4 customers per 10 minutes on average. Simulate 12 intervals:
arrivals = rng.poisson(lam=4, size=12)
print(arrivals)
print("busiest interval:", arrivals.max(), "customers")
[6 3 6 8 1 6 2 7 3 0 6 4]
busiest interval: 8 customers

Mean equals variance

A special property of the Poisson distribution: its mean and its variance are both λ.

python · try it yourself
import numpy as np

rng = np.random.default_rng(42)
calls = rng.poisson(lam=6.5, size=100_000)       # calls per hour
print(f"mean     {calls.mean():.3f}")
print(f"variance {calls.var():.3f}")
print(f"P(no calls in an hour) ~ {np.mean(calls == 0):.4f}")
mean     6.502
variance 6.487
P(no calls in an hour) ~ 0.0015

The probability of a quiet hour (0 calls) is tiny when λ = 6.5. Theory says it is e^(−λ) ≈ 0.0015, close to the simulated value.

Visualising Poisson distributions

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(42)
plt.figure(figsize=(6, 3.5))
for lam, color in [(1, "#e07a5f"), (4, "#4dabcf"), (10, "#81b29a")]:
    x = rng.poisson(lam, size=10_000)
    values, counts = np.unique(x, return_counts=True)
    plt.plot(values, counts / x.size, "o-", color=color, label=f"lambda = {lam}")
plt.xlabel("events per interval")
plt.ylabel("probability")
plt.legend()
plt.tight_layout()
plt.show()
print("Plotted Poisson distributions for lambda 1, 4 and 10")
Plotted Poisson distributions for lambda 1, 4 and 10

For small λ the distribution is lopsided, piled up near 0. As λ grows, it moves right, spreads out and becomes more symmetric.

Poisson vs binomial

The two are closely related. A binomial with a large n and a small p (many chances, each unlikely) behaves like a Poisson with λ = n·p. Think of 10,000 drivers on a road each with a 0.0003 chance of an accident: binomial(10000, 0.0003) ≈ Poisson(3).

python · try it yourself
import numpy as np

rng = np.random.default_rng(7)
binom = rng.binomial(n=10_000, p=0.0003, size=50_000)
pois = rng.poisson(lam=3, size=50_000)
for k in range(7):
    print(f"k={k}: binomial {np.mean(binom == k):.3f}   poisson {np.mean(pois == k):.3f}")
k=0: binomial 0.049   poisson 0.048
k=1: binomial 0.148   poisson 0.148
k=2: binomial 0.229   poisson 0.226
k=3: binomial 0.218   poisson 0.224
k=4: binomial 0.169   poisson 0.166
k=5: binomial 0.102   poisson 0.104
k=6: binomial 0.052   poisson 0.050

The frequencies match to about two decimal places.

Binomial Poisson
Counts successes in n trials events in an interval
Maximum n no maximum
Parameters n, p lam
Mean / variance np / np(1−p) λ / λ

Test yourself

What does the lam parameter of rng.poisson represent?

  1. The maximum count
  2. The average number of events per interval
  3. The probability of one event
  4. The number of intervals

For a Poisson distribution with lambda = 5, what is the variance?

  1. sqrt(5)
  2. 5
  3. 25
  4. 2.5

Which scenario is best modelled by a Poisson distribution?

  1. Heights of students
  2. Number of heads in 10 tosses
  3. Number of website sign-ups per hour
  4. Time between two buses