The median is the middle value in a sorted dataset. It's one of the three main measures of central tendency — alongside the mean and mode — and it's particularly useful when your data contains outliers or skewed values.

What Is the Median?

The median splits a dataset exactly in half: 50% of values fall below it, and 50% fall above it. Unlike the mean, the median isn't affected by extreme values.

Example: The median salary of $50,000 tells you more about a typical worker than a mean salary of $90,000 that's been pulled up by a handful of executives earning millions.

How to Find the Median: Odd Number of Values

Step 1: Sort all values in ascending order (smallest to largest).

Step 2: Find the middle value — the one with an equal number of values on each side.

Example: Dataset: 7, 3, 5, 1, 9

  1. Sort: 1, 3, 5, 7, 9
  2. The middle value is 5 (2 values below, 2 values above)

The median is 5.

How to Find the Median: Even Number of Values

When there's an even number of values, there's no single middle value — you have two. The median is the mean of those two middle values.

Step 1: Sort all values in ascending order.

Step 2: Identify the two middle values.

Step 3: Add them together and divide by 2.

Example: Dataset: 4, 8, 6, 2, 10, 3

  1. Sort: 2, 3, 4, 6, 8, 10
  2. The two middle values are 4 and 6
  3. Median = (4 + 6) / 2 = 5

The median is 5.

Finding the Middle Position

For any dataset of n values, the middle position is:

  • Odd n: Position = (n + 1) / 2
  • Even n: Average positions n/2 and (n/2) + 1
n valuesMiddle position
5Position 3
7Position 4
10Average of positions 5 and 6
12Average of positions 6 and 7

Worked Example: Larger Dataset

Dataset: 14, 23, 8, 31, 17, 5, 29, 11, 20, 18, 25, 9

Step 1: Count: 12 values (even)

Step 2: Sort: 5, 8, 9, 11, 14, 17, 18, 20, 23, 25, 29, 31

Step 3: Middle positions are 6th and 7th values = 17 and 18

Step 4: Median = (17 + 18) / 2 = 17.5

Median vs Mean: Which Should You Use?

SituationBetter measure
Data has outliersMedian
Data is skewed (e.g., income)Median
Symmetric distributionEither (mean is more precise)
Categorical or ordinal dataMedian
Need to use in further calculationsMean

Rule of thumb: If your mean and median are very different, your data is skewed. Report the median as the more representative value.

Median of Grouped Data

When data is presented in frequency tables or grouped intervals, you can estimate the median using interpolation.

Example:

ScoreFrequencyCumulative Frequency
0–2033
21–40710
41–601222
61–80830
81–100535

Total: 35 values. The median is the 18th value (position = (35+1)/2 = 18).

The 18th value falls in the 41–60 group (cumulative frequency reaches 22 in this group, having been 10 before it).

Median ≈ L + [(n/2 − F) / f] × h

Where:

  • L = lower boundary of median class = 41
  • n = total frequency = 35
  • F = cumulative frequency before median class = 10
  • f = frequency of median class = 12
  • h = class width = 20
Median ≈ 41 + [(17.5 − 10) / 12] × 20
        ≈ 41 + [7.5 / 12] × 20
        ≈ 41 + 12.5
        ≈ 53.5

Weighted Median

When data points have different weights or importance, use the weighted median — the value at which the cumulative weight reaches 50%.

Real-World Examples

House prices: The median house price in a city better represents a "typical" house than the mean, which can be skewed by a few luxury properties.

Test scores: If most students score 60–70 but a few score 100, the median score is more informative than the mean.

Response times: In web performance, the median response time shows what a typical user experiences, whereas the mean can be thrown off by occasional slow requests.

Common Mistakes

Not sorting first — You must sort the data before finding the middle value.

Off-by-one on the position — For 9 values, the median is at position 5, not position 4.5.

Using the mean for even datasets — For an even number of values, always average the two middle values.


Read Next