The Poisson Distribution
How many emails arrive in an hour, how many typos per page, how many requests per second hit a server, how many mutations in a stretch of DNA? Whenever many independent opportunities each have a tiny chance of producing an event, the count has approximately a Poisson distribution.
Definition
A random variable is Poisson with mean if
The probabilities sum to 1 because . Both the mean and the variance equal .
The Poisson approximation to the binomial
Let and with fixed. Then
because and . In practice the approximation is good when is large and small.
from math import comb, exp, factorial
n, p = 1000, 0.003
lam = n * p
print(" k binomial Poisson")
for k in range(9):
b = comb(n, k) * p ** k * (1 - p) ** (n - k)
po = exp(-lam) * lam ** k / factorial(k)
print(f"{k:2d} {b:.5f} {po:.5f}") k binomial Poisson
0 0.04956 0.04979
1 0.14914 0.14936
2 0.22415 0.22404
3 0.22438 0.22404
4 0.16828 0.16803
5 0.10087 0.10082
6 0.05033 0.05041
7 0.02151 0.02160
8 0.00803 0.00810
Poisson processes
Events that happen "at random in time" at an average rate per unit time form a Poisson process: the number of events in an interval of length is Poisson with mean , counts in disjoint intervals are independent, and the gaps between events are exponential with rate . Simulating with exponential gaps and counting per unit interval gives Poisson counts:
import random
from collections import Counter
from math import exp, factorial
rng = random.Random(4)
lam, T = 2.5, 40_000
t, counts = 0.0, Counter()
while True:
t += rng.expovariate(lam)
if t >= T:
break
counts[int(t)] += 1
per_interval = Counter(counts[i] for i in range(T))
for k in range(8):
print(f"P(N={k}) ~ {per_interval[k] / T:.4f} Poisson {exp(-lam) * lam ** k / factorial(k):.4f}")P(N=0) ~ 0.0816 Poisson 0.0821
P(N=1) ~ 0.2059 Poisson 0.2052
P(N=2) ~ 0.2559 Poisson 0.2565
P(N=3) ~ 0.2166 Poisson 0.2138
P(N=4) ~ 0.1324 Poisson 0.1336
P(N=5) ~ 0.0653 Poisson 0.0668
P(N=6) ~ 0.0283 Poisson 0.0278
P(N=7) ~ 0.0096 Poisson 0.0099
Clumping and the "hot hand"
Random events cluster more than people expect. With an average of 2.5 events per minute, a minute with 6 or more events happens about 4% of the time, so in a day of 1440 minutes there are about 60 such "bursts", with nothing special causing them. Before blaming a cause for a spike in errors or crimes, compare it with the Poisson tail.
from math import exp, factorial
lam = 2.5
tail = 1 - sum(exp(-lam) * lam ** k / factorial(k) for k in range(6))
print("P(N >= 6) =", round(tail, 4), " expected bursts per day:", round(1440 * tail, 1))
lam_day = 3 # incidents per day, on average
p_zero = exp(-lam_day)
print("P(a quiet day with no incidents) =", round(p_zero, 4))P(N >= 6) = 0.042 expected bursts per day: 60.5
P(a quiet day with no incidents) = 0.0498
In software
Queueing models for servers start from Poisson arrivals: with arrival rate and a single server of rate , the average queue grows like where , exploding as utilization approaches 1. Load testing tools generate Poisson traffic, and alerting thresholds ("page if errors per minute exceed ") are set from Poisson tails so that random fluctuations do not wake anyone up.
Exercises
Exercise 1: Typos
A book has on average 1.5 typos per page. What is the probability that a page has no typo? At least 2?
Answer
; .
Solution
Poisson with : , , so .
Exercise 2: Rare defects
A chip has 10,000 transistors, each defective with probability 0.0002, independently. Approximate the probability that the chip has at most one defect.
Answer
About .
Solution
; .
Exercise 3: Sums of Poissons (code)
Sum independent Poisson(1) and Poisson(2) samples with NumPy and compare the distribution with Poisson(3).
Answer
They agree: independent Poisson variables add to a Poisson with the summed mean.
Solution
This follows from generating functions or from merging two independent Poisson processes.
import numpy as np
from math import exp, factorial
rng = np.random.default_rng(7)
s = rng.poisson(1.0, 200_000) + rng.poisson(2.0, 200_000)
for k in range(7):
print(k, round((s == k).mean(), 4), round(exp(-3) * 3 ** k / factorial(k), 4))0 0.0507 0.0498
1 0.1499 0.1494
2 0.2223 0.224
3 0.2259 0.224
4 0.1674 0.168
5 0.0997 0.1008
6 0.0505 0.0504
Test yourself
The mean and variance of a Poisson distribution with parameter are…
- and
- both
- and
- and
When is the binomial distribution well approximated by a Poisson?
- small, near 1/2
- large, small, moderate
- always
- Never
In a Poisson process, the gaps between events are…
- uniform
- normal
- exponential
- constant