Concept map / Poisson distribution

Share

The Poisson distribution

Vary the event rate and the window length, read cumulative probabilities, and check by simulation that a Poisson count's variance equals its mean.

1How many requests land in a window?

Requests reach a help desk at a steady average rate, each independent of the others. The number that arrive in a fixed window then has a Poisson distribution with mean λ, the rate times the window length. It is what a binomial count becomes when time is cut into many tiny slices, each with a small chance of an arrival.

At 2 requests per minute, how likely is a 2-minute window with 3 or fewer? Change the rate and the window, move the cut c, and simulate windows to compare their counts with the bars.

0.00.150.3024681012ProbabilityRequests in the window (k)
P(X ≤ 3)More than 3Mean λ, with a bar one standard deviation either side

At 2.0 requests per minute over 2 minutes, the mean count is λ = 4.0. The chance of 3 or fewer requests is 43.3%. The variance also equals 4.0, so the standard deviation is 2.00.

More controls

2A window four times as long: how much more spread?

Requests arrive at 2 per minute. A 2-minute window has a mean count of 4. An 8-minute window has a mean count of 16, four times as many. Compared with the short window, how spread out is the count in the long window?

3One parameter for the mean and the variance

The Poisson distribution has one parameter, the mean count λ = rate × window length. That same λ is the variance, so a larger mean always brings a larger spread. Point at λ or k and the mean line or the cut bar in section 1 lights up.

P(X=k)=e−λ λkk!E[X]=Var⁡(X)=λ\begin{gathered} P(X = \htmlClass{term-k}{k}) = \frac{e^{-\htmlClass{term-lam}{\lambda}}\,\htmlClass{term-lam}{\lambda}^{\htmlClass{term-k}{k}}}{\htmlClass{term-k}{k}!} \\ E[X] = \operatorname{Var}(X) = \htmlClass{term-lam}{\lambda} \end{gathered}

Now: P(X = 3) = e−4.0 × 4.03 / 3! = 0.195, and adding the bars from 0 to 3 gives P(X ≤ 3) = 0.433. The 95th percentile of the count is 8.

4Check yourself

The tasks use the sliders and buttons in section 1 and tick themselves when you meet them.

  • Find a rate and window where the chance of zero requests is below 1%.Now: λ = 4.0, P(X = 0) = 1.8%
  • Set the cut to the smallest count c with P(X ≤ c) of at least 95%.Now: c = 3, P(X ≤ 3) = 43.3%
  • Simulate at least 200 windows and get the sample variance within 10% of the sample mean.Now: no windows simulated yet

5Poisson counts in R

dpois() gives P(X = k), ppois() adds the bars up to a cut, and qpois() finds the smallest count whose cumulative probability reaches a target. At the page’s default λ = 4 the snippet prints 0.195 and 0.433, a 95th percentile of 8, and 200 simulated windows with mean 4.14 and variance 4.22.

Poisson counts in a windowShow the code
# 2 requests per minute over a 2-minute window
rate <- 2
minutes <- 2
lambda <- rate * minutes

# P(X = 3) and P(X <= 3), as on the page
round(c(exactly = dpois(3, lambda),
        at_most = ppois(3, lambda)), 3)

# Smallest count c with P(X <= c) of at least 95%
qpois(0.95, lambda)

# Simulate 200 windows: mean and variance are both near 4
set.seed(4)
counts <- rpois(200, lambda)
round(c(mean = mean(counts), variance = var(counts)), 2)

# Quadrupling the mean doubles the standard deviation
round(sqrt(c(short = 4, long = 16)), 2)

Uses base R only.

What one rate decides