Choose random inputsLesson 09 of 76 · 7 min

Count arrivals in an interval

Use a Poisson model with an explicitly scaled observation interval.

A Poisson count takes nonnegative integer values with no fixed upper limit. A homogeneous process has a constant event rate. Independent increments means counts in non-overlapping time intervals do not inform each other under the model; for example, the first half-hour's count does not change the next half-hour's distribution.

If the rate is four requests per hour, the expected count in half an hour is two. NumPy poisson takes that expected count, not a rate with unspecified units. Keep the duration conversion visible in the model.

Under this model the count variance equals its mean. Real observations with bursts, seasonality or shared causes may have more variation. Comparing empirical mean and variance is a useful diagnostic, although matching them would not prove the whole model.

λwindow\lambda_{\rm window} is the expected number of arrivals in the chosen window; probability mass is the chance of each integer count.

Scale the rate to the observation window
02.557.51000.0780.160.230.31Probability massArrivals per half-hour
02.557.51000.0780.160.230.31Probability massArrivals per half-hour
λwindow=4×0.5=2\lambda_{\rm window}=4\times0.5=2
Reference illustration. Exact Poisson reference for 4 arrivals per hour over 0.5 hours: expected count 2. The plotted range is 0–10, but Poisson support has no finite upper bound.

For a rate of four per hour, what mean belongs in a half-hour count generator?

Write a prediction (optional)

Seeded teaching simulation

Select Run Python below with the code unchanged.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

Published example output

This result comes from the original Python. Your runs appear above. Build environment ↗

Model expected count: 2.0
Sample mean / variance: 1.98 1.975
Estimated P(no arrivals): 0.138
Exact model P(no arrivals): 0.1353

Read the first result

The rate-times-duration product supplies the generator’s expected count. A larger interval changes the count distribution.

Try an edit

Replace rate_per_hour, hours = 4, .5 with rate_per_hour, hours = 4, 2. Select Run Python again. Read Model expected count and compare both P(no arrivals) values with the first run. What happens to the chance of seeing zero when the window gets longer?

Back to the Python editor

Scope. A constant-rate Poisson model omits burstiness, periodicity and arrival dependence.

Try a fresh case

A generator expects a mean count. You supply an hourly rate while modelling ten minutes. What is missing?

Choose an answer
Need a hint?
Hint 1

Write the rate’s units beside the duration.

Hint 2

Check that the product has units of events.

Your notes