SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 5.4.1 Densities, distribution functions and the uniform distributionConcept · 30 min
      2. 5.4.2 The exponential distributionConcept · 25 min
      3. 5.4.3 The normal distributionConcept · 30 min
      4. 5.4.4 The lognormal, Student t and chi-squared distributionsConcept · 30 min
      5. 5.4.5 Practice set: continuous distributionsPractice set · 25 min
      6. 5.4.6 Case study: lognormal prices and fat-tailed returnsCase study · 35 min

Level 5, Probability and statistics 5.4 Continuous distributions Lesson 2 of 6

ConceptLesson 5.4.2 in Level 5, Probability and statistics. About 25 minutes.

The exponential distribution

Waiting at a constant rate

Some events arrive at a steady rate λ\lambda (lambda) per unit of time: calls to a help desk, or failures of a machine part. Each moment carries the same small chance of the event, whatever has happened before. The waiting time XX until the next event then has the exponential distribution, written X∼Exp(λ)X \sim \text{Exp}(\lambda).

Rule: Exponential distribution

f(x)=λe−λx,x≥0F(x)=1−e−λxP(X>x)=e−λx\begin{gathered} f(x) = \lambda e^{-\lambda x}, \quad x \ge 0 \\[4pt] F(x) = 1 - e^{-\lambda x} \\[4pt] P(X > x) = e^{-\lambda x} \end{gathered}

λ>0\lambda > 0 is a rate, in events per unit of time; xx is a time, in the same unit. The density is 0 for x<0x < 0: a wait cannot be negative. The tail P(X>x)P(X > x), the chance of waiting longer than xx, falls by the factor e−λe^{-\lambda} each unit of time.

The total area is 1, the exponential tail of lesson 2.6.3: ∫0∞λe−λx dx=λ⋅1λ=1\int_0^\infty \lambda e^{-\lambda x}\,dx = \lambda \cdot \frac{1}{\lambda} = 1. FF is the area from 0 to xx, [−e−λt]0x=1−e−λx\big[-e^{-\lambda t}\big]_0^x = 1 - e^{-\lambda x} (lesson 2.5.3), and its slope is λe−λx\lambda e^{-\lambda x} again.

A machine part fails at a rate of 0.2 a year. Its life XX in years has P(X>5)=e−1≈0.367879P(X > 5) = e^{-1} \approx 0.367879 and P(X≤2)=1−e−0.4≈0.32968P(X \le 2) = 1 - e^{-0.4} \approx 0.32968.

A help desk gets 3 calls an hour. The wait for the next call has λ=3\lambda = 3 per hour, which is 0.050.05 per minute. Waiting more than 30 minutes has probability e−3×0.5=e−0.05×30≈0.22313e^{-3 \times 0.5} = e^{-0.05 \times 30} \approx 0.22313: the same answer in either unit, as long as λ\lambda and xx agree.

The density starts at its peak, f(0)=λf(0) = \lambda, so short waits are the likeliest. With λ=3\lambda = 3 per hour that peak is 3, above 1: a density, not a probability (lesson 5.4.1).

Case study 2.5.5 used this density for the time until a borrower defaults, with λ\lambda the hazard rate.

Mean and variance by parts

The mean wait is an improper integral (lesson 2.6.3) that needs integration by parts (lesson 2.6.2). Take u=xu = x and dv=λe−λx dxdv = \lambda e^{-\lambda x}\,dx, so du=dxdu = dx and v=−e−λxv = -e^{-\lambda x}:

E[X]=∫0∞x λe−λx dx=[−x e−λx]0∞+∫0∞e−λx dx=0+1λ\begin{aligned} \mathbb{E}[X] &= \int_0^\infty x\,\lambda e^{-\lambda x}\,dx \\ &= \big[-x\,e^{-\lambda x}\big]_0^\infty + \int_0^\infty e^{-\lambda x}\,dx \\ &= 0 + \frac{1}{\lambda} \end{aligned}

The bracket is 0 at both ends: at 0 because of the factor xx, and at infinity because eλxe^{\lambda x} outgrows xx (lesson 2.1.3). Parts again gives E[X2]=2λE[X]=2λ2\mathbb{E}[X^2] = \frac{2}{\lambda}\mathbb{E}[X] = \frac{2}{\lambda^2}.

Rule: Mean and variance of the exponential

E[X]=1λVar⁡(X)=2λ2−1λ2=1λ2\begin{gathered} \mathbb{E}[X] = \frac{1}{\lambda} \\[4pt] \operatorname{Var}(X) = \frac{2}{\lambda^2} - \frac{1}{\lambda^2} = \frac{1}{\lambda^2} \end{gathered}

A rate of 0.2 failures a year means a mean life of 5 years. The standard deviation, 1λ\frac{1}{\lambda}, equals the mean.

Try it

quad checks the total area, the mean and E[X2]\mathbb{E}[X^2] for λ=0.2\lambda = 0.2, with math.inf as the upper limit (lesson 2.6.3).

Each line prints the integral next to the formula. round hides float noise in the last digits.

⌘/Ctrl + Enter runs the cell

Quantiles and the median

Solve 1−e−λxp=p1 - e^{-\lambda x_p} = p with logs (lesson 1.4.4) to get the quantile.

Rule: Exponential quantiles

xp=−ln⁡(1−p)λmedian=ln⁡2λ≈0.693λ\begin{gathered} x_p = -\frac{\ln(1 - p)}{\lambda} \\[4pt] \text{median} = \frac{\ln 2}{\lambda} \approx \frac{0.693}{\lambda} \end{gathered}

The median is about 0.69 of the mean: the long right tail pulls the mean up. For a decaying atom the median is called the half-life.

For the machine part, the median life is ln⁡20.2≈3.465736\frac{\ln 2}{0.2} \approx 3.465736 years, shorter than the mean of 5. Only e−1≈0.367879e^{-1} \approx 0.367879 of parts outlive the mean, whatever λ\lambda is.

Raise λ\lambda: the curve starts higher and falls faster, and the dashed mean 1λ\frac{1}{\lambda} moves left. The interval starts as [0,1λ][0, \frac{1}{\lambda}]; it holds 0.6321 at every λ\lambda, since 1−e−1≈0.6321211 - e^{-1} \approx 0.632121.

Explore

The curve is a density: probabilities are areas under it. Change the parameters, then set an interval and read the shaded area.

024600.51

The dashed line is the mean.

Probability
P(0 ≤ X ≤ 1) = 0.6321
Mean
1
Variance
1, so the standard deviation is 1

Try it

SciPy's expon takes scale =1λ= \frac{1}{\lambda}, the mean, not the rate. NumPy's rng.exponential does the same.

The last line is the trap: expon(3) shifts the density to start at 3, so its mean is 4. A rate of 3 is expon(scale=1/3).

⌘/Ctrl + Enter runs the cell

Memorylessness

A part that has already run for 3 years fails at the same rate as a new one. So the chance it lasts 2 more years is the chance that a new part lasts 2. By conditional probability (lesson 5.1.3), the event "more than 5" is inside "more than 3":

P(X>5∣X>3)=P(X>5)P(X>3)=e−0.2×5e−0.2×3=e−0.2×2≈0.67032\begin{aligned} P(X > 5 \mid X > 3) &= \frac{P(X > 5)}{P(X > 3)} \\ &= \frac{e^{-0.2 \times 5}}{e^{-0.2 \times 3}} = e^{-0.2 \times 2} \\ &\approx 0.67032 \end{aligned}

That is P(X>2)P(X > 2) exactly. The 3 years already survived drop out.

Rule: Memorylessness

P(X>s+t∣X>s)=P(X>t)P(X > s + t \mid X > s) = P(X > t)

For s,t≥0s, t \ge 0. Having waited ss tells you nothing about the further wait. The exponential is the only continuous distribution with this property; the geometric (lesson 5.2.2) is its discrete cousin.

The exponential density with λ=0.5\lambda = 0.5, and its tail beyond 2 moved back to 0 and divided by its area, 0.368. The result is the original density: beyond one more unit lies 0.607 of it, as for a new start.

The rule only fits a constant rate. A part that wears out fails more often as it ages, so its life is not exponential. The formula would understate the risk for old parts.

Try it

One seeded run draws a million lifetimes with mean 5 and keeps the parts still working at 3 years.

Among those, the share that lasts beyond 5 is close to 0.67032, the share of new parts lasting beyond 2. Their mean remaining life is close to 5 years, the mean of a new part.

⌘/Ctrl + Enter runs the cell

Exponential gaps make Poisson counts

Calls arrive at rate λ\lambda, so the gaps between them are independent exponential waits. Count the calls in a window of length tt and you get a Poisson count with mean λt\lambda t (lesson 5.2.3). The two descriptions fit together: no call in the window is the same event as a first wait longer than tt.

Rule: Exponential and Poisson

Nt∼Poisson(λt)P(Nt=0)=e−λt=P(X>t)\begin{gathered} N_t \sim \text{Poisson}(\lambda t) \\[4pt] P(N_t = 0) = e^{-\lambda t} = P(X > t) \end{gathered}

NtN_t is the number of events in a window of length tt, and XX the wait for the first. The rate links the two: the mean count is λt\lambda t, and the mean gap is 1λ\frac{1}{\lambda}.

For the help desk, 3 calls an hour, simulate 100,000 hours. Each hour adds exponential gaps of mean 13\frac{1}{3} hour until it passes 1, and counts the calls.

calls in the hour0123456
share of simulated hours0.050.15020.22250.22540.16670.10030.0517
Poisson(3) pmf0.04980.14940.2240.2240.1680.10080.0504

The shares are from one seeded run and agree with the pmf to about two decimal places. The mean count is 2.99969, close to λt=3\lambda t = 3.

Try it

rng.exponential(scale=1/3, size=(100_000, 20)) draws 20 gaps for each hour; cumsum turns them into arrival times. More than 20 calls in an hour has probability below 10−1010^{-10}, so 20 is enough.

(times <= 1).sum(axis=1) counts the arrivals inside each hour.

⌘/Ctrl + Enter runs the cell

Lesson 5.4.3 turns to the normal distribution, the bell curve of lesson 2.6.3.

Common mistakes

  1. SciPy and NumPy take the mean, not the rate. expon(scale=1/lam) and rng.exponential(scale=1/lam); expon(3) is a shifted density.
  2. Match the units. A rate per hour needs times in hours: 30 minutes is x=0.5x = 0.5.
  3. Half the waits are shorter than the median, ln⁡2λ\frac{\ln 2}{\lambda}, not the mean. Only 0.3679 of them exceed the mean.
  4. The past does not count. P(X>5∣X>3)P(X > 5 \mid X > 3) is P(X>2)P(X > 2), not P(X>5)P(X > 5).
  5. The variance is 1λ2\frac{1}{\lambda^2}, not 1λ\frac{1}{\lambda}; the standard deviation equals the mean.
  6. Only a constant rate gives an exponential. Wear-out, or a rate that changes through the day, breaks memorylessness.

The exponential distribution

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • A wait at a constant rate λ\lambda has density λe−λx\lambda e^{-\lambda x} for x≥0x \ge 0, distribution function 1−e−λx1 - e^{-\lambda x} and tail P(X>x)=e−λxP(X > x) = e^{-\lambda x}. Keep λ\lambda and xx in the same time unit.
  • E[X]=1λ\mathbb{E}[X] = \frac{1}{\lambda} and Var⁡(X)=1λ2\operatorname{Var}(X) = \frac{1}{\lambda^2}, by parts; the median is ln⁡2λ\frac{\ln 2}{\lambda}, and xp=−ln⁡(1−p)λx_p = -\frac{\ln(1 - p)}{\lambda}.
  • Memorylessness: P(X>s+t∣X>s)=P(X>t)P(X > s + t \mid X > s) = P(X > t).
  • Exponential gaps at rate λ\lambda give a Poisson⁡(λt)\operatorname{Poisson}(\lambda t) count in a window of length tt, and P(Nt=0)=e−λtP(N_t = 0) = e^{-\lambda t}.
  • In SciPy and NumPy, scale is the mean 1λ\frac{1}{\lambda}.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.