AI Hints
Home›Data Science Tutorial›Randomness in Business
Data Science · Lesson 48 of 101

Modelling Arrivals

The maths of busy mornings.

⏱ 2 min read▶ Video at 1:21:21🎓 Free
Watch this lesson in the Data Science courseWatch on YouTube ↗Full Data Science course

Every morning, the Oslo cafe gets about thirty six customers an hour. Sometimes four arrive in a minute, and then nobody comes for five. The manager thinks that something strange is going on. But that clumping is exactly what randomness looks like. People expect random events to be evenly spaced, and they aren't. There's a distribution that describes this perfectly.

Modelling Arrivals
From the video: Modelling Arrivals
  • About thirty six customers an hour
  • Sometimes four in one minute
  • Randomness comes in clumps

The Poisson distribution

When events arrive independently, at a steady average rate, counts follow a Poisson distribution. We simulate a hundred thousand ten minute windows, with an average of six customers. Run it. There's a lovely property here. The mean and the variance are both six. That's a quick test for whether your data is really Poisson. And now we can answer useful questions. The chance of twelve or more in ten minutes, which is double the normal rate, is about two percent. In a busy cafe, that happens several times each week. So that rush isn't unusual. It's normal, and it's what you've got to staff for. The chance of nobody at all is a quarter of a percent.

arrivals.pypython
import numpy as np
from scipy import stats

rng = np.random.default_rng(0)
customers = rng.poisson(6, 100000)

print("Average per 10 minutes:", round(customers.mean(), 2))
print("Variance:", round(customers.var(), 2))
print(f"Chance of 12 or more: {stats.poisson.sf(11, 6):.1%}")
print(f"Chance of none:       {stats.poisson.pmf(0, 6):.2%}")
Output
Average per 10 minutes: 6.0
Variance: 6.03
Chance of 12 or more: 2.0%
Chance of none:       0.25%

Where Poisson shows up

Poisson counts show up all over the place. Support tickets per hour. Website visits per minute. Defects per crate. Equipment failures per month. Whenever someone says, we had a terrible day, three machines broke, ask how unusual that really is. If the variance is much larger than the mean, then events aren't independent. Something's causing them to cluster, such as a marketing email, and it's worth finding out what.

Tickets, visits, defectsall count data
Mean equals variancea quick test
Variance far largerevents are linked
Is it unusual?work it out

Summary

Random arrivals come in clumps, and you can calculate how often. So how many staff do you need? Averages will give you the wrong answer.

Key takeaways
  • Poisson models random counts
  • Mean equals variance
  • Rushes are normal
Next up: How Many Baristas? — why averages lie about queues