Descriptive Statistics
Summarise and visualise data before analysing it. Learn mean, median and mode, range, variance and standard deviation, percentiles, quartiles and IQR, outliers, skewness and kurtosis, histograms, box plots, scatter plots and probability plots.
Test results, sensor logs and production measurements are only useful once summarised. Descriptive statistics reveal the centre, spread and shape of data and flag outliers that could indicate faults.
An analogy
Descriptive statistics are like a quick health check-up for data: a few vital signs (mean, spread, shape) tell you whether something looks unusual.
Centre
Mean uses all values but is pulled by outliers; median is robust; mode is the most frequent value. For skewed data (repair times, incomes) report the median.
Spread
Range is simple but sensitive to extremes; standard deviation is standard (use n − 1 for samples); IQR is robust. Box plots show median, quartiles and outliers at a glance.
Shape and plots
Histograms show distribution shape; skewness measures asymmetry; kurtosis tail weight. Normal probability plots test normality (points on a line). Scatter plots show relationships.
Data quality
Check units, missing values, sensor dropouts and outliers before analysis. Investigate outliers rather than deleting them automatically — they may be the most important data.
Formulas
- Mean:
x̄ = Σxᵢ/n - Sample variance:
s² = Σ(xᵢ − x̄)²/(n − 1) - Outlier fences:
below Q₁ − 1.5 IQR or above Q₃ + 1.5 IQR - Coefficient of variation:
CV = s/x̄
Worked example: Shaft diameters
Given: 12.1, 11.8, 12.4, 12.0, 11.9, 12.3, 12.2, 11.7, 12.0, 12.6 mm
Find: Mean, median, s.
- Mean = 121.0/10 = 12.10
- Sorted middle values 12.0, 12.1 → median 12.05
- s = 0.279 mm
Answer: 12.10, 12.05, 0.279 mm
Worked example: Outlier check
Given: Q₁ = 11.9, Q₃ = 12.3
Find: Fences.
- IQR = 0.4
- Fences 11.3 and 12.9
Answer: No outliers (12.6 is within)
Summaries, confidence interval, t-test and Cpk (Python)
import statistics as st
from math import sqrt
# Shaft diameters (mm) from a production sample
d = [12.1, 11.8, 12.4, 12.0, 11.9, 12.3, 12.2, 11.7, 12.0, 12.6]
n, mean, s = len(d), st.mean(d), st.stdev(d)
t95 = 2.262 # t(0.975, df = 9)
half = t95 * s / sqrt(n)
print(f"n = {n}, mean = {mean:.3f}, median = {st.median(d):.3f}, s = {s:.4f}")
print(f"95% CI for the mean: {mean - half:.3f} .. {mean + half:.3f} mm")
# One-sample t statistic against the nominal 12.0 mm
t = (mean - 12.0) / (s / sqrt(n))
print(f"t = {t:.3f} (|t| < 2.262 -> no significant shift at 5%)")
# Process capability with spec 11.2 .. 12.8 mm
cpk = min(12.8 - mean, mean - 11.2) / (3 * s)
print(f"Cpk = {cpk:.3f}")
# n = 10, mean = 12.100, median = 12.050, s = 0.2789
# 95% CI for the mean: 11.901 .. 12.299 mm
# t = 1.134 (|t| < 2.262 -> no significant shift at 5%)
# Cpk = 0.837The whole statistics workflow of this module in a few lines: describe, estimate with a confidence interval, test a hypothesis, and judge capability against specifications.
Common mistakes
- Wrong: Dividing by n for sample variance. — Right: Use n − 1 (unbiased).
- Wrong: Reporting mean for highly skewed data. — Right: Report median and IQR too.
Applications
- Quality reports: Summaries of production measurements.
- Test data: Characterising prototypes.
- Condition monitoring: Detecting abnormal readings.
Key takeaways
- Centre: mean, median, mode.
- Spread: s, IQR, range.
- Shape: histograms, skewness, probability plots.
- Investigate outliers.
Going further
- Robust statistics: Trimmed means, MAD.
- Kernel density estimates: Smooth histograms.
- Exploratory data analysis: Tukey's methods.