Learning outcomes
By the end of this lesson you should be able to: compute the mean and median of a small dataset; explain what each measures and one meaningful thing they tell you differently; and recognise when a skewed distribution means you should reach for the median rather than the mean.
Prerequisites
Lesson 1 (What is data & variables). You need to be able to tell a numerical variable from a categorical one, because the mean and median summarise numerical data only.
The big idea
Both measure the center of a numerical variable, but they answer different questions and respond differently to the shape of the data. The mean uses every value, so a single very large or very small observation can pull it hard. The median ignores the sizes of the extremes and only cares about position in the ordering, so it is largely unmoved by a single outlier. Choosing between them is one of the most consequential decisions in descriptive statistics, and it is driven by one thing: the shape, especially whether the data is skewed.
Why this matters before the arithmetic
For a perfectly symmetric distribution, the mean and the median agree, or nearly so. The mean is well-behaved because the values on each side tend to balance. But real datasets are rarely symmetric. House prices, incomes, and reaction times are all right-skewed: a few unusually large values stretch the right tail far out. Those large values pull the mean up, but they do not move the median because the median only cares about which value sits at the halfway point.
The practical consequence is this: when data is skewed, the mean stops being a good description of a 'typical' value. Reported as a 'typical' price, it overstates the truth, because a handful of luxury properties drag the average well above what most people pay. The median is the honest summary of the center in that case. This is exactly why median house price is the figure reported in the news, not mean house price.
A common beginner's misunderstanding is to assume the mean is always the 'right' average. It is a perfectly fine summary — for symmetric data. But the choice is a judgement about the data's shape, not a matter of which one is more rigorous. Both are rigorous; each is appropriate for a different situation, and knowing which is which is the skill.
Worked example 1: center of a symmetric dataset
For roughly symmetric data the mean and median sit close together. Here they are identical.
data = [4, 5, 5, 6, 6, 6, 7, 7, 8]
n = len(data)
mean = sum(data) / n
s = sorted(data)
if n % 2 == 1:
median = s[n // 2]
else:
median = (s[n // 2 - 1] + s[n // 2]) / 2
print("mean:", mean)
print("median:", median)mean: 6.0
median: 6The values cluster around 6 and are spread fairly evenly on either side. The total is 54 across 9 observations, so the mean is 6. Sorted, the middle value (the fifth one) is also 6, so the median is 6. When the data is not skewed, the two measures agree and it does not matter much which you report.
Worked example 2: a skew pulls the mean away from the median
Add a single enormous value — an outlier — and watch how the mean jumps while the median barely changes. This is the whole reason the median exists.
data = [200, 250, 260, 280, 900]
n = len(data)
mean = sum(data) / n
s = sorted(data)
if n % 2 == 1:
median = s[n // 2]
else:
median = (s[n // 2 - 1] + s[n // 2]) / 2
print("mean:", mean)
print("median:", median)
print("mean exceeds median by", round(mean - median, 1))mean: 378.0
median: 260
mean exceeds median by 118.0Four of the five values are between 200 and 280 — they cluster tightly. The fifth, 900, is far to the right. The mean adds all five and divides by five, so the huge 900 drags the average up to 378 even though four of five values are below 280. The median simply finds the middle sorted value, which is 260, and is entirely unconcerned with how far 900 is from the rest. Median 260 is the honest 'typical' value here; mean 378 is the average torn toward the outlier.
Common mistakes
Watch outReporting the mean for heavily skewed data. A skewed distribution makes the mean misleading, torn toward the long tail. Describe the center with the median instead.
Watch outSorting incorrectly. The median requires the data in order. Unsorted, the 'middle' is meaningless — always sort first.
Watch outForgetting the even-count median. With an even number of observations, the median is the average of the two middle values, not either one alone.
Watch outAssuming mean and median are interchangeable. They measure the center differently and diverge under skew. The choice is about the data's shape, not convenience.
Check your understanding
A dataset has five values: 2, 3, 4, 5, 100. Why is the median a better summary of the center than the mean?
How do you find the median when there is an even number of observations?
When is the mean an appropriate measure of center?
Multiple choice
What is the mean of the data {10, 12, 14}?
What is the median of {1, 3, 7, 9, 100}?
What is the median of {2, 4, 6, 8}?
House prices in a city are heavily right-skewed. Which is the best headline summary of a 'typical' price?
Why does one large outlier have little effect on the median?
Which statement about the mean is true?
A dataset is symmetric. Which is most likely true of its mean and median?
To find a median, what must you do first?
Summary and next
The mean is the sum divided by the count and uses every value. The median is the middle value once sorted. They measure the same thing — the center — but the mean is sensitive to skew and outliers while the median is not. Summarise skewed data with the median and symmetric data with either.
Next: spread & shape. Lesson 2 told you where the data sits; the next lesson tells you how far it stretches — variance, standard deviation, quartiles and the shape of a histogram — because two datasets can share a center and still be completely different.