Course: Statistics and Probability for Data Science (DS14270).
Source deck: Samer El Kababji, SD05 — Discrete Distributions .
The Poisson distribution models counts of events in a fixed interval when the events occur independently at a stable average rate.
Probability mass function
If \(X\sim\operatorname{Poisson}(\mu)\) , then
\[
P(X=x)=e^{-\mu}\frac{\mu^x}{x!},
\qquad x=0,1,2,\ldots,
\]
where \(\mu>0\) is the expected count per interval.
Code
mu <- 2.4
x <- 0 : 10
formula_pmf <- exp (- mu) * mu^ x / factorial (x)
R_pmf <- dpois (x, lambda = mu)
data.frame (x, formula_pmf, R_pmf)
x formula_pmf R_pmf
1 0 0.0907179533 0.0907179533
2 1 0.2177230879 0.2177230879
3 2 0.2612677055 0.2612677055
4 3 0.2090141644 0.2090141644
5 4 0.1254084986 0.1254084986
6 5 0.0601960793 0.0601960793
7 6 0.0240784317 0.0240784317
8 7 0.0082554623 0.0082554623
9 8 0.0024766387 0.0024766387
10 9 0.0006604370 0.0006604370
11 10 0.0001585049 0.0001585049
Tile-defect example
If a tile has an average of \(\mu=2.4\) defects, then
\[
P(X=0)=e^{-2.4}\approx0.0907.
\]
The probability of at least four defects is easiest through the complement:
\[
P(X\geq4)=1-P(X\leq3)\approx0.2213.
\]
Code
c (
no_defects = dpois (0 , lambda = 2.4 ),
at_least_four = ppois (3 , lambda = 2.4 , lower.tail = FALSE ),
complement_check = 1 - ppois (3 , lambda = 2.4 )
)
no_defects at_least_four complement_check
0.09071795 0.22127709 0.22127709
Using lower.tail = FALSE avoids manually subtracting from 1 and can be more accurate for very small upper-tail probabilities.
Mean and variance
The Poisson parameter controls both center and spread:
\[
E(X)=\mu,\qquad
\operatorname{Var}(X)=\mu,\qquad
\operatorname{SD}(X)=\sqrt{\mu}.
\]
Code
mu <- 2.4
c (mean = mu, variance = mu, sd = sqrt (mu))
mean variance sd
2.400000 2.400000 1.549193
Equality of the mean and variance is a distinctive Poisson property. Strong overdispersion or underdispersion in observed counts can signal that a simple Poisson model is inadequate.
Changing the interval
If the rate is 2.4 events per hour, the expected count in \(t\) hours is \(\mu_t=2.4t\) .
Code
rate_per_hour <- 2.4
hours <- c (0.5 , 1 , 3 )
mu_by_interval <- rate_per_hour * hours
data.frame (
hours,
expected_count = mu_by_interval,
P_no_events = dpois (0 , lambda = mu_by_interval)
)
hours expected_count P_no_events
1 0.5 1.2 0.3011942119
2 1.0 2.4 0.0907179533
3 3.0 7.2 0.0007465858
Poisson approximation to the binomial
For \(X\sim\operatorname{Bin}(n,p)\) , if \(n\) is large and \(p\) is small while \(np\to\mu\) , then
\[
X\ \dot\sim\ \operatorname{Poisson}(\mu),\qquad \mu=np.
\]
The deck’s practical rule is \(n>50\) and \(np<5\) .
Code
n <- 200
p <- 0.01
mu <- n * p
k <- 0 : 8
comparison <- data.frame (
k,
binomial = dbinom (k, size = n, prob = p),
poisson = dpois (k, lambda = mu)
)
comparison$ absolute_difference <- abs (comparison$ binomial - comparison$ poisson)
comparison
k binomial poisson absolute_difference
1 0 0.1339796749 0.1353352832 1.355608e-03
2 1 0.2706660098 0.2706705665 4.556659e-06
3 2 0.2720330099 0.2706705665 1.362443e-03
4 3 0.1813553399 0.1804470443 9.082956e-04
5 4 0.0902197019 0.0902235222 3.820233e-06
6 5 0.0357233567 0.0360894089 3.660521e-04
7 6 0.0117273646 0.0120298030 3.024384e-04
8 7 0.0032829852 0.0034370866 1.541014e-04
9 8 0.0008000204 0.0008592716 5.925126e-05
Simulation check (fictional extension)
Code
set.seed (14270 )
simulated_counts <- rpois (100000 , lambda = 2.4 )
c (
simulated_mean = mean (simulated_counts),
simulated_variance = var (simulated_counts),
theoretical_value = 2.4
)
simulated_mean simulated_variance theoretical_value
2.390470 2.403167 2.400000
Practice questions
A help desk averages 3.5 calls per hour. Find \(P(X=2)\) in one hour.
Find \(P(X\geq5)\) in one hour.
Find the probability of no calls in 30 minutes.
Approximate \(P(X=1)\) for \(X\sim\operatorname{Bin}(100,0.02)\) with a Poisson distribution.
dpois(2, 3.5) gives approximately \(0.1850\) .
ppois(4, 3.5, lower.tail = FALSE) gives approximately \(0.2746\) .
The half-hour mean is \(1.75\) , so the probability is \(e^{-1.75}\approx0.1738\) .
Use \(\mu=np=2\) : dpois(1, 2) gives approximately \(0.2707\) (the exact binomial value is about \(0.2707\) ).