AI Hints
Home›Statistics & Math for ML Tutorial›Common Distributions
Statistics & Math for ML · Lesson 41 of 138

The Poisson Distribution

Counting events.

⏱ 2 min read▶ Video at 46:49🎓 Free
Watch this lesson in the Statistics & Math for ML courseWatch on YouTube ↗Full Statistics & Math for ML course

A help desk gets four emails an hour, on average. How likely is a quiet hour with none? Or a crazy hour with ten? When we count events that happen at random over time, we use the Poisson distribution.

The Poisson Distribution
From the video: The Poisson Distribution
  • Four emails an hour, on average
  • A quiet hour? A crazy hour?
  • Poisson: counting events

One setting, lambda

The Poisson distribution has just one setting, lambda, the average count. Here, lambda is four. Run it. A completely quiet hour has under a two percent chance. Ten or more emails is under one percent. So if you get ten in an hour, something unusual is probably going on.

poisson.pypython
from scipy.stats import poisson

lam = 4

print("no emails:  ", round(poisson.pmf(0, lam), 4))
print("exactly 4:  ", round(poisson.pmf(4, lam), 4))
print("10 or more: ", round(poisson.sf(9, lam), 4))
Output
no emails:   0.0183
exactly 4:   0.1954
10 or more:  0.0081

Different averages

Here's the shape for three different averages. With a small lambda, the counts bunch up near zero. With a bigger lambda, the shape moves right and spreads out. Run it.

poisson_plot.pypython
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson

k = np.arange(0, 20)
for lam in [1, 4, 10]:
    plt.plot(k, poisson.pmf(k, lam), "o-", label=f"lambda = {lam}")
plt.title("Poisson counts"); plt.legend()
plt.savefig("poisson.png")

Summary

The Poisson distribution counts random events in a fixed time, using one number, the average lambda. Next, the uniform distribution.

Key takeaways
  • One setting: lambda
  • poisson.pmf / sf
  • Calls, clicks, arrivals
Next up: The Uniform Distribution — all equally likely