Data Analysis for Engineers/Module 3

Module 3 · Section 9 of 11

Lesson 3.8 - Probability Distributions & Return Periods

Target: ~10 min read - 25 min hands-on

Overview

scipy.stats provides ready-made distributions - Normal, Lognormal, and Gumbel (Extreme Value) among them - used constantly in engineering risk analysis. This lesson introduces return periods: a "50-year peak" doesn't mean it happens once every 50 years like clockwork - it means a 1-in-50 (2%) chance of being equaled or exceeded in any given year. We'll analyze annual peak electrical demand with the Gumbel method, the direct rehearsal for Mini-Project 3.

Why This Matters (Engineering Context)

The Gumbel Extreme Value method sizes anything driven by a rare maximum - a substation transformer against peak demand, a relief system against a worst-case surge, a structure against extreme wind, a drainage culvert against a flood. Same math, many fields.

Code-Along

from scipy import stats
import numpy as np

np.random.seed(21)

# [Electrical] synthesise a 30-year record of annual peak demand (MW)
# by drawing from a Gumbel (extreme-value) distribution
n_years = 30
annual_peak = np.round(stats.gumbel_r.rvs(loc=180, scale=25, size=n_years, random_state=21), 1)
print("Annual peak demand (MW), 30-year record:")
print(annual_peak)

# .fit() estimates the distribution parameters that best match the data
loc_fit, scale_fit = stats.gumbel_r.fit(annual_peak)
print(f"\nFitted Gumbel: loc={loc_fit:.2f}, scale={scale_fit:.2f}")

# Return period T <-> non-exceedance probability (1 - 1/T).
# .ppf (percent-point function) is the inverse CDF: probability -> value.
for T in [10, 25, 50, 100]:
    x_T = stats.gumbel_r.ppf(1 - 1 / T, loc=loc_fit, scale=scale_fit)
    print(f"  {T}-year return-period peak: {x_T:.1f} MW")

# Same idea with a Normal fit, to show the distribution choice matters
mu, sigma = stats.norm.fit(annual_peak)
print(f"\n100-yr peak, Normal fit:  {stats.norm.ppf(0.99, mu, sigma):.1f} MW")   # 0.99 = 1 - 1/100
print(f"100-yr peak, Gumbel fit:  {stats.gumbel_r.ppf(0.99, loc_fit, scale_fit):.1f} MW")
print("(Gumbel is built for extremes; Normal usually understates the tail.)")

Run it: the Gumbel return-period peaks increase with return period (10-yr < 25-yr < 50-yr < 100-yr), and the Normal fit typically gives a lower (less conservative) 100-year estimate - a concrete illustration of why distribution choice is a real engineering decision.

Practice Exercises

  1. Compute the 5-year and 200-year return-period peaks using the fitted Gumbel.
  2. What is the probability that the peak exceeds the 50-year value in any given year? (Hint: 1/T.)
  3. Fit a Lognormal distribution (stats.lognorm.fit, with floc=0) to the same data and compare its 100-year estimate to the Gumbel and Normal results.
# Try the practice exercises here

Knowledge Check

  1. What does a "50-year peak" actually mean in probability terms?
  2. Which distribution family is standard for extreme-value / return-period analysis?
  3. Why might a Normal fit understate the risk of a rare extreme compared to a Gumbel fit?
Answer key
  1. A value with a 1-in-50 (2%) chance of being equaled or exceeded in any given year
  2. The Gumbel (Extreme Value Type I) distribution
  3. The Normal has thinner tails than distributions built to model extremes, so it underpredicts rare maxima

31 / 63 sections · Course home · Join the coaching cohort