What the median is
The median is the middle value of a dataset once the numbers are sorted from smallest to largest. Exactly half of the values fall at or below the median and half fall at or above it, which is why the median is also called the 50th percentile or the second quartile (Q2).
How to calculate the median
There are only two cases, and they depend on whether you have an odd or even count of values (n):
- Odd count (n is odd): sort the values and take the single middle one — the value at position (n + 1) / 2. For 3, 5, 8, 12, 20, 21, 22 there are 7 values, so the median is the 4th value: 12.
- Even count (n is even): sort the values and take the two middle values — positions n/2 and n/2 + 1 — then average them. For 3, 5, 8, 10 the two middle values are 5 and 8, so the median is (5 + 8) / 2 = 6.5.
Sorting is the only step people skip; the values must be in order before you pick the middle. Duplicate values are counted individually — they are not collapsed into one entry.
Median vs. mean vs. mode
- Median: the middle value. It is resistant to outliers, so it is the honest "typical" figure for skewed data such as household income, home prices, or wait times.
- Mean (average): the sum divided by the count. It uses every value's exact magnitude, so a single extreme value pulls it up or down. Best for roughly symmetric data.
- Mode: the most frequently occurring value. Useful for categorical data or spotting the most common outcome.
When the mean is noticeably larger than the median, the data is right-skewed (a few large values stretch the tail). When the mean is smaller than the median, the data is left-skewed. When they are equal, the data is symmetric.
Why the median matters
Because it ignores how far the extremes are and only cares about position, the median is the standard measure of center for money and time. "Median household income" and "median home sale price" are reported precisely because one billionaire or one mansion would badly distort the mean, while the median stays anchored to the middle household. The median is also the center line of a box plot, and Q3 − Q1 (the interquartile range) is the box's height.