Before any modelling, A/B test, or machine-learning pipeline, you summarise your data. Descriptive statistics are the toolkit — six numbers that tell you almost everything about a column.
Why descriptive stats?
- Spot data-quality issues — outliers, wrong units, encoding errors.
- Choose the right model — many ML algorithms assume roughly-normal features.
- Communicate results — "median order value rose 12%" is easier than dumping a CSV.
Measures of central tendency
| Measure | Formula / definition | When to prefer it |
|---|---|---|
| Mean (μ) | sum / n | no extreme outliers, roughly-symmetric data |
| Median | middle value (sorted) | skewed data, presence of outliers |
| Mode | most frequent value | categorical data; multimodal distributions |
Measures of spread
| Measure | What it tells you |
|---|---|
| Range | max − min (very sensitive to outliers) |
| Variance (σ²) | average squared deviation from the mean |
| Std deviation (σ) | √variance — same units as the data |
| IQR | Q3 − Q1 (robust to outliers) |
For a roughly normal distribution, the 68/95/99.7 rule holds:
- ~68% of values fall within 1σ of the mean
- ~95% within 2σ
- ~99.7% within 3σ
Percentiles & quartiles
The Pth percentile is the value below which P% of the data falls. Quartiles (Q1, Q2, Q3) are the 25th, 50th, 75th percentiles. The Inter-Quartile Range (IQR) = Q3 − Q1.
Standard outlier rule: any value below Q1 − 1.5·IQR or above Q3 + 1.5·IQR is flagged as an outlier (this is what box-plot whiskers visualise).
Skewness & kurtosis
- Skewness measures asymmetry. Right-skew (positive) is common in income & revenue data — a long right tail.
- Kurtosis measures tail-heaviness. High kurtosis = more extreme outliers than a normal distribution would predict.
Computing them in Python
import numpy as npimport pandas as pdsalaries = pd.Series([35, 42, 50, 58, 60, 60, 72, 90, 110, 350])print(salaries.mean()) # 92.7 — pulled up by the 350print(salaries.median()) # 60.0 — robustprint(salaries.mode().tolist()) # [60]print(salaries.std()) # 95.4print(salaries.var()) # 9106print(salaries.quantile([0.25, 0.5, 0.75]))print(salaries.describe()) # all of the above in one go# Custom: compute the 95th percentileprint(np.percentile(salaries, 95))
Key takeaways
- 01Mean is sensitive to outliers; median is robust. Default to median for skewed data.
- 02Standard deviation has the same units as your data; variance is in units squared.
- 03For a normal distribution: ~68/95/99.7 of values lie within 1/2/3 std devs.
- 04Outliers are values outside Q1 − 1.5·IQR or Q3 + 1.5·IQR.
- 05In Python, df.describe() prints all the descriptives at once — start there every time.
