CCalclabhub

Statistics

How To Calculate The Median

The median is the number that sits in the middle, and it is the statistic that survives an outlier when the average does not.

Quick Answer

median = middle value once the data is sorted

median
Middle value of the ordered data
n
How many values there are

Put the values in order and take the middle one. For 12, 5 and 9 the sorted order is 5, 9, 12, so the median is 9. With an even count, average the two middle values instead.

What Is The Median?

The median is the middle value of a set of numbers once they have been arranged in order. For the three values twelve, five and nine, the sorted list is five, nine, twelve, and the median is nine.

Ordering is the essential first step and the one most often skipped. Reading a value off an unsorted list gives a number that looks reasonable but is not the median at all, and there is no way to tell from the result that it is wrong.

With an odd number of values there is a single middle one. With an even number there is no single middle, so the median is defined as the average of the two central values. Four values have their median halfway between the second and the third.

The median is a positional statistic. It depends on where a value sits in the order, not on how large it is. Changing the largest value from twelve to a thousand does not move the median at all, which is exactly the property that makes it useful.

That robustness is why income and house prices are usually reported as medians rather than averages. A handful of extremely large values drags a mean upward, while the median stays where the typical case actually is.

The mean and the median answer different questions. The mean is the total divided by the count, the value each would get if everything were shared equally. The median is the value that half the data lies below and half above.

When the two differ substantially, the distribution is skewed. A mean well above the median says a few large values are pulling the total up, which is the signature of income, wealth and property price distributions.

The range is a related but separate measure: the largest value minus the smallest. It is easy to compute and extremely sensitive to outliers, which is the opposite of the median's behaviour.

For three values there is a neat shortcut. The median equals the sum of all three minus the smallest minus the largest. It gives the same answer as sorting and is convenient when you are working with a formula rather than a list.

The median is well defined for any numeric data, but not for categories. You can order shoe sizes and find a median, but you cannot order colours. For categorical data the mode is the appropriate summary instead.

Finally, be careful with an even count. Forgetting to average the two middle values and simply picking one of them is the most common error, and on small data sets it can shift the answer noticeably.

Formula

median = middle value, or mean of the two middle values

Sort first. With an odd count take the middle value; with an even count average the two central values.

SymbolMeaning
medianMedian
nCount

range = largest - smallest

A measure of spread rather than of centre, and far more sensitive to outliers than the median is.

SymbolMeaning
RRange
largestMaximum
smallestMinimum

How To Calculate The Median

  1. 1

    Write the values out in order

    Smallest to largest, or largest to smallest, it makes no difference. Skipping this step is the single most common reason for a wrong median.

  2. 2

    Count how many values there are

    The count decides which rule applies. An odd count has one middle value, an even count has two and needs an extra averaging step.

  3. 3

    Find the middle position

    With three values the middle is the second one, which is nine in the list five, nine, twelve. With four values the middle positions are the second and third.

  4. 4

    Average the two middle values if the count is even

    For the values two, four, eight and ten the middle pair is four and eight, so the median is six. Reporting four or eight instead is a common slip.

  5. 5

    Compare with the mean before drawing conclusions

    If the mean and the median are far apart, the data is skewed and the median is usually the more honest summary of the typical case.

Examples

Example 1: Three values, twelve five and nine

Value A
12
Value B
5
Value C
9
StepCalculationResult
Smallestmin(12, 5, 9)5
Largestmax(12, 5, 9)12
Median12 + 5 + 9 - 5 - 129

Result: Ordered as 5, 9, 12, the median is 9, and the range between the extremes is 7.

Example 2: Three values, three eight and one

Value A
3
Value B
8
Value C
1
StepCalculationResult
Smallestmin(3, 8, 1)1
Largestmax(3, 8, 1)8
Median3 + 8 + 1 - 1 - 83

Result: Ordered as 1, 3, 8, the median is 3 even though the mean of the same three values is 4.

Example 3: Three house prices, 20, 14 and 17

Value A
20
Value B
14
Value C
17
StepCalculationResult
Smallestmin(20, 14, 17)14
Largestmax(20, 14, 17)20
Median20 + 14 + 17 - 14 - 2017

Result: The median price is 17, which is the middle of the market rather than the 17 that a mean would also give on these three values.

Calculator

Median

9

Smallest
5
Largest
12
Range
7

Values update as you type. This calculator covers the single scenario its formula assumes — see Common Mistakes for what it leaves out.

Prefer a full-width tool? Open the The Median calculator page.

Common Mistakes

  • Not sorting the values first

    The median is a positional statistic. Reading the middle entry of an unsorted list gives a number with no meaning, and nothing about it looks wrong.

  • Forgetting to average the two middle values

    With an even count there is no single middle value. Picking one of the pair instead of averaging them biases the answer towards whichever end you happened to pick.

  • Confusing the median with the mean

    The mean is the total divided by the count and is affected by every value. The median is the middle position and ignores how extreme the other values are.

  • Assuming the median must be one of the data values

    With an even count the median can be a value that does not appear in the data at all, such as 6 for the set two, four, eight, ten.

  • Using the median on categorical data

    Medians need an order. Colours or labels cannot be sorted meaningfully, so the mode is the right summary for that kind of data.

  • Reporting the median as if it were the total

    The median is a single typical value, not a sum. Multiplying it by the count does not give the total unless every value happens to be identical.

  • Ignoring how far the mean and median diverge

    A large gap between them is information about the shape of the data. Reporting only one of the two hides the skew entirely.

FAQ

How do you find the median?

Put the values in order and take the middle one. For 12, 5 and 9 the sorted list is 5, 9, 12, so the median is 9.

What if there is an even number of values?

Average the two middle values. For two, four, eight and ten the middle pair is four and eight, so the median is six.

Why is the median better than the mean for income?

Because a few extremely high incomes pull the mean upward. The median describes what a typical person earns, unaffected by how large the top values are.

Can the median be a value that is not in the data?

Yes. Whenever the count is even, the median is the average of two values and may not appear in the set at all.

Does the median change if the largest value changes?

No, not unless the change reorders the values around the middle. Replacing twelve with a thousand leaves a median of nine untouched.

What is the difference between the median and the mode?

The median is the middle value in order, while the mode is the value that appears most often. The median needs numeric data, the mode works for categories too.

References

  1. [1]Wikipedia, Median — https://en.wikipedia.org/wiki/Median
  2. [2]Wikipedia, Robust statistics — https://en.wikipedia.org/wiki/Robust_statistics
  3. [3]Wikipedia, Skewness — https://en.wikipedia.org/wiki/Skewness
  4. [4]Wikipedia, Average — https://en.wikipedia.org/wiki/Average