Stellar Grove · Research

Stellar Grove · Concrete Mathematical Modelling

How sure is the predicted wait?

A day of observations pins down the arrival and service rates fairly well. How precisely does that pin down the wait?

Chapter 8 · Using a model: choice and estimation. A worked example rebuilt from the chapter's topic in Mike Mesterton-Gibbons, *A Concrete Approach to Mathematical Modelling*; the scenario and numbers are our own illustration, not the book's text. The day of observations is simulated from known rates, so the estimates can be checked against the truth.

Headline: Rates estimated to within about ±16% give a predicted wait of 2.7 minutes, but the 95% interval runs from 1.4 to 6 minutes: each 1% error in λ moves the wait by 2.4%, and that multiplier explodes as utilisation nears 1.

The problem

An analyst times one checkout lane for a day: 148 customers, recording the gap since the previous arrival and each service time. The M/M/1 model then predicts the mean wait Wq=λ/(μ(μ−λ)). How much should the store trust that number?

Estimating the inputs

For exponential times the maximum-likelihood rate is the reciprocal of the mean, with an exact interval from the chi-square distribution:

λ^=n∑isi,[χ2n,0.02522∑isi,χ2n,0.97522∑isi]

Arrivals: λ^=0.309 a minute (0.261–0.361); services: μ^=0.527 (0.445–0.615). Estimated utilisation ρ^=0.59.

Propagating the uncertainty

Two ways to carry input uncertainty to the output. The delta method linearises the formula; on the log scale (waits are positive and skewed):

se(lnW^q)≈∇lnWq⊤Σ∇lnWq,Σ=diag(λ^2n,μ^2n)

That gives 1.4–5 minutes. The bootstrap resamples the observed gaps and service times 4,000 times and recomputes the wait each time: 1.4–6 minutes. In 0% of resamples λ^≥μ^ and the model predicts an ever-growing queue.

Bootstrap distribution of the predicted wait: long right tail, truth inside the interval
Bootstrap distribution of the predicted wait: long right tail, truth inside the interval

Try it

Precision of the predicted wait

The band is the approximate 95% interval (delta method) for the wait, given how many customers were observed.

Key findings

Truth checks

CheckResult
95% interval for λ covers 0.3pass
95% interval for μ covers 0.5pass
Bootstrap interval for the wait covers the true 3 minpass
import numpy as np
from books.concrete_mathematics import estimation as es
rng = np.random.default_rng(8)
gaps = rng.exponential(1 / 0.3, 400)
gaps = gaps[np.cumsum(gaps) <= 480]
service = rng.exponential(1 / 0.5, gaps.size)
wq = lambda l, m: l / (m * (m - l)) if l < m else np.nan
print([round(x, 1) for x in es.bootstrap(lambda g, s: wq(g.size / g.sum(), s.size / s.sum()), gaps, service, n=4000, rng=1)])

# → [2.7, 1.4, 6.4]

Assumptions and extensions