Concept map / Exponential distribution

Share

The exponential distribution

Read the chance of waiting longer than a given time in a constant-rate process, compare the mean wait with the median, and test memorylessness.

Prerequisites Poisson distribution

1How long until the next request?

The Poisson page counts events that arrive at a constant rate λ. The same process also fixes how long you wait from any moment to the next event. That wait has an exponential distribution, a continuous distribution on positive times whose density is highest at zero and falls from there.

At 0.5 requests per minute, how likely is a wait of more than 3 minutes, and is a typical wait as long as the mean? Set λ and a wait t. The shaded area right of t is the chance of waiting longer. The height of the curve is a density, not a probability.

0.00.30.6024681012Density (per minute)Wait until the next request (minutes)
P(T > 3.0), the area to the rightMean wait 1/λ

At a rate of 0.50 requests per minute, the mean wait is 2.00 minutes. The chance of waiting longer than 3.0 minutes is 22.3%. Half of all waits are shorter than 1.39 minutes, the median, and 63.2% are shorter than the mean.

More controls

2Three quiet minutes: is a request now due?

Requests arrive at a constant rate of 0.5 per minute, so the mean wait is 2 minutes. You have already waited 3 minutes with no request. What is the chance that you wait more than 2 further minutes?

3The chance of waiting past t

The distribution is set by its rate λ, the events per minute, which is also what the rate argument of R's dexp() takes. The mean wait is 1/λ. Point at a term and the matching part of the chart in section 1 lights up.

f(t)=λ e−λtP(T>t)=e−λt,E[T]=1λ\begin{gathered} f(t) = \htmlClass{term-lam}{\lambda}\, e^{-\htmlClass{term-lam}{\lambda} \htmlClass{term-time}{t}} \\ P(T > \htmlClass{term-time}{t}) = e^{-\htmlClass{term-lam}{\lambda} \htmlClass{term-time}{t}}, \quad E[T] = \frac{1}{\htmlClass{term-lam}{\lambda}} \end{gathered}

Now: P(T > 3.0) = e−0.50 × 3.0 = e−1.50 = 0.223. The mean wait is 1/0.50 = 2.00 minutes and the median is ln 2/λ = 1.39 minutes.

Why a quiet stretch changes nothing
P(T>s+t∣T>s)=e−λ(s+t)e−λs=e−λt\begin{gathered} P(T > s + t \mid T > s) \\ = \frac{e^{-\lambda (s + t)}}{e^{-\lambda s}} = e^{-\lambda t} \end{gathered}

After s quiet minutes, the chance of waiting t more is the chance of waiting t from the start. This is called memorylessness. Under a constant rate, no request is ever overdue.

4Check yourself

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

  • Set the rate so that the mean wait is 4 minutes.Now: rate 0.50 per minute, mean wait 2.00 minutes
  • Find a wait t for which the chance of waiting longer is between 45% and 55%. Compare that t with the mean wait.Now: P(T > 3.0) = 22.3%, mean wait 2.00 minutes
  • Simulate at least 1,000 waits and check that about 63% are shorter than the mean: get the share between 61% and 65%.Now: no waits simulated yet

5Simulate waits in R

R’s dexp(), pexp() and rexp() take the same rate λ through their rate argument, and the mean wait is 1/λ. At the page’s default λ = 0.5 the snippet prints a 0.223 chance of waiting more than 3 minutes, a median of 1.386 minutes, 0.632 of waits below the mean, and the memoryless check 0.368 = 0.368.

Exponential waiting timesShow the code
# Rate lambda = 0.5 requests per minute, as on the page.
# R's dexp() and pexp() take the same rate; the mean
# wait is 1 / rate = 2 minutes.
rate <- 0.5

# Chance of waiting longer than 3 minutes
round(pexp(3, rate, lower.tail = FALSE), 3)

# Median wait, and the share of waits below the mean
round(c(median = qexp(0.5, rate),
        below_mean = pexp(2, rate)), 3)

# Memorylessness: P(T > 5 | T > 3) equals P(T > 2)
surv <- function(t) pexp(t, rate, lower.tail = FALSE)
round(c(after_3 = surv(5) / surv(3), start = surv(2)), 3)

# Simulate 1,000 waits
set.seed(5)
waits <- rexp(1000, rate)
round(c(mean = mean(waits), below_mean = mean(waits < 2)), 3)

Uses base R only.

What a constant rate implies