Module 5 · Section 2 of 12
Lesson 5.1 - Descriptive Statistics Review
Target: ~9 min read - 15 min hands-on
Overview
A quick review: mean and median describe the center of a distribution (and disagree when data is skewed); variance and standard deviation describe spread; skewness measures asymmetry; kurtosis measures tail heaviness. These directly inform engineering tolerance decisions - like how wide a spec must be to capture 99% of output.
Why This Matters (Engineering Context)
A skewed distribution - like time-between-failures, or repair durations, mostly short with occasional long ones - means the mean is a misleading summary on its own. When the audience will act on the number (a spares budget, an SLA), report the full shape.
Code-Along
# One roughly symmetric quantity vs one strongly right-skewed quantity
bore_mm = np.random.normal(40.00, 0.05, 500) # Normal -> symmetric, bell-shaped
gap_hours = np.random.exponential(60, 500) # Exponential -> long right tail
for name, data in [("Bore diameter (mm)", bore_mm), ("Hours between stops", gap_hours)]:
print(f"--- {name} ---")
print(f" Mean: {np.mean(data):.3f}")
print(f" Median: {np.median(data):.3f}") # mean == median only if symmetric
print(f" Std dev: {np.std(data, ddof=1):.3f}") # ddof=1 -> sample std dev
print(f" Skewness: {stats.skew(data):.2f}") # 0 = symmetric, >0 = right tail
print(f" Kurtosis: {stats.kurtosis(data):.2f}") # 0 = Normal-like tails (excess kurtosis)
print()
fig, axes = plt.subplots(1, 2, figsize=(11, 4))
axes[0].hist(bore_mm, bins=30, color="steelblue", edgecolor="white")
axes[0].axvline(np.mean(bore_mm), color="red", label="Mean") # axvline = vertical line
axes[0].axvline(np.median(bore_mm), color="green", linestyle="--", label="Median")
axes[0].set_title("Bore Diameter (roughly symmetric)"); axes[0].legend()
axes[1].hist(gap_hours, bins=30, color="teal", edgecolor="white")
axes[1].axvline(np.mean(gap_hours), color="red", label="Mean") # note: mean sits right of median
axes[1].axvline(np.median(gap_hours), color="green", linestyle="--", label="Median")
axes[1].set_title("Hours Between Stops (right-skewed)"); axes[1].legend()
plt.tight_layout(); plt.show()
Run it: the bore-diameter histogram is roughly bell-shaped with mean ~ median and skewness near 0. The hours-between-stops histogram has a long right tail, with the mean pulled noticeably higher than the median and a clearly positive skewness - the signature of skewed real-world reliability data.
Practice Exercises
- Compute the same five statistics for equipment time-to-failure
(
np.random.weibull(1.5, 500) * 1000hours) - is it skewed? - For the
gap_hoursdata, compute the 95th percentile and compare it to the mean - what does the gap imply about planning maintenance windows on the average alone? - Generate a high-kurtosis dataset (
np.random.standard_t(df=3, size=500)) and compare its histogram shape to a Normal's.
# Try the practice exercises here
Knowledge Check
- Why can the mean and median disagree substantially for a skewed dataset?
- What does positive skewness indicate about a distribution's tail?
- Why might reporting only the mean of a skewed engineering dataset be misleading?
Answer key
- The mean is pulled toward extreme values in the tail; the median resists that pull
- A longer/heavier tail on the right (toward high values)
- It hides that the typical (median) value differs from the mean, and that rare extremes pull the average up
45 / 63 sections · Course home · Join the coaching cohort