A measure of central tendency captures the "typical" value of a dataset in a single number. The three you need are the mean, median and mode — and knowing when to use each matters as much as computing them.
The three measures
| Measure | Is | Best when |
|---|---|---|
| Mean | The average (sum ÷ count) | Data is symmetric, no big outliers |
| Median | The middle value when sorted | Data is skewed or has outliers |
| Mode | The most frequent value | Categorical data, or finding peaks |
import numpy as npdata = [2, 3, 3, 5, 100]np.mean(data) # 22.6 — pulled up by the outliernp.median(data) # 3.0 — robust to the outlier
Mean vs median
Key takeaways
- 01Central tendency captures the "typical" value: mean, median, mode.
- 02The mean is the average; sensitive to outliers and skew.
- 03The median (middle value) is robust to outliers — prefer it for skewed data.
- 04The mode is the most frequent value; useful for categorical data.
