When data is given as a frequency table with class intervals, you cannot see the individual values, so you estimate the median by linear interpolation inside the class that contains it:
Median = L + ((n/2 − F) / f) × w
- L is the lower boundary of the median class
- n is the total frequency
- F is the cumulative frequency before the median class
- f is the frequency of the median class
- w is the class width
The formula assumes the values in the median class are spread evenly across it, then reads off the point that has half the data below it. The same idea gives quartiles and any percentile. You can check the arithmetic with our interpolation calculator.
Why this is interpolation
Picture the cumulative frequency rising across a class. At the lower boundary L, F values are below. At the upper boundary, F + f values are below. If the values in the class are spread evenly, the cumulative count rises in a straight line between those two points. The median is where that line reaches n/2.
So the formula is linear interpolation between (L, F) and (L + w, F + f), solved for the x that gives n/2. Strictly, it is inverse interpolation: you know the count you want and solve for the value.
Worked example: commute times
A survey of 60 people recorded their one-way commute time in minutes:
| Commute time (minutes) | Frequency (f) | Cumulative frequency |
|---|---|---|
| 0 to under 10 | 6 | 6 |
| 10 to under 20 | 14 | 20 |
| 20 to under 30 | 22 | 42 |
| 30 to under 40 | 11 | 53 |
| 40 to under 50 | 5 | 58 |
| 50 to under 60 | 2 | 60 |
n = 60.
Step 1: find the median position
n/2 = 60/2 = 30. The median is the value with 30 observations below it.
Step 2: find the median class
Look down the cumulative frequency column for the first value of 30 or more. It is 42, in the class 20 to under 30. So:
- L = 20
- F = 20 (cumulative frequency before this class)
- f = 22
- w = 10
Step 3: apply the formula
- n/2 − F = 30 − 20 = 10
- 10 / 22 = 0.4545
- Median = 20 + 0.4545 × 10 = 24.55 minutes
In words: we need 10 more people beyond the 20 already counted, and this class has 22, so we go 10/22 of the way through its 10-minute width.
Quartiles and percentiles
Replace n/2 with the position you need:
- Lower quartile Q1: n/4
- Upper quartile Q3: 3n/4
- k-th percentile Pₖ: k × n / 100
Same formula otherwise: value = L + ((position − F) / f) × w.
Q1 (position 15)
Position 15 falls in the 10 to 20 class (cumulative frequency goes from 6 to 20).
- Q1 = 10 + ((15 − 6) / 14) × 10 = 10 + 0.6429 × 10 = 16.43 minutes
Q3 (position 45)
Position 45 falls in the 30 to 40 class (cumulative frequency goes from 42 to 53).
- Q3 = 30 + ((45 − 42) / 11) × 10 = 30 + 0.2727 × 10 = 32.73 minutes
Interquartile range
IQR = Q3 − Q1 = 32.73 − 16.43 = 16.30 minutes (16.2987 before rounding). Half the people in the survey commute between about 16 and 33 minutes.
90th percentile (position 54)
0.90 × 60 = 54. Position 54 falls in the 40 to 50 class (cumulative frequency goes from 53 to 58).
- P90 = 40 + ((54 − 53) / 5) × 10 = 40 + 0.2 × 10 = 42.0 minutes
So about 10% of people commute 42 minutes or more.
A percentile that lands on a boundary
The 10th percentile is at position 0.10 × 60 = 6. The first class ends with cumulative frequency exactly 6, so the formula gives 0 + (6/6) × 10 = 10.0 minutes, the class boundary itself. That is expected: exactly 6 people commute under 10 minutes.
The ogive view
An ogive is the graph of cumulative frequency against upper class boundaries. For this data the points are (0, 0), (10, 6), (20, 20), (30, 42), (40, 53), (50, 58) and (60, 60). Joining them with straight lines and reading across from 30 on the vertical axis gives the median on the horizontal axis.
Because the ogive is drawn with straight lines, reading it is the same calculation as the formula. Draw it carefully and you will read about 24.5 minutes for the median, matching 24.55. A curved freehand ogive gives a slightly different answer, which is why exam mark schemes usually allow a small range.
Check it with the calculator
Use the two ogive points either side of the median: (20, 20) and (30, 42). On the calculator, put cumulative frequency as x and the class boundary as y, then ask for the boundary at a cumulative frequency of 30:
| Field | Value |
|---|---|
| X1 | 20 |
| Y1 | 20 |
| X2 | 42 |
| Y2 | 30 |
| X3 | 30 |
| Y3 | leave empty |
Y3 shows 24.55, the median in minutes. For Q1, enter X1 = 6, Y1 = 10, X2 = 20, Y2 = 20, X3 = 15 and you get 16.43.
Common mistakes
- Using class limits instead of boundaries. If classes are written as whole numbers such as 10 to 19 and 20 to 29, the true boundaries are 9.5, 19.5, 29.5 and so on, and L must be the boundary. Using 20 instead of 19.5 shifts every answer by half a unit.
- Using F from the wrong row. F is the cumulative frequency before the median class, not including it.
- Unequal class widths. The formula works with any widths, but use the width w of the class you are in, not a common width.
- n/2 or (n + 1)/2? For grouped data the usual convention is n/2. The (n + 1)/2 rule is for finding the middle of a list of individual values. Follow the convention your course or textbook uses, as answers differ slightly.
- Reading the grouped median as exact. It is an estimate based on the even-spread assumption. With the raw data you can find the true median directly.
Median vs mean for grouped data
The grouped mean uses class midpoints: Σ(midpoint × f) / n. For the commute data it is 25.17 minutes, slightly above the median of 24.55 because the long-commute tail (40 to 60 minutes) pulls the mean up. When a distribution is skewed like this, the median is usually the better “typical” value.
Related reading
- Linear interpolation: the basics
- Inverse interpolation: finding x when you know y
- How to interpolate t, z and chi-square tables
FAQ
What is the formula for the median of grouped data? Median = L + ((n/2 − F) / f) × w, where L is the lower boundary of the median class, F the cumulative frequency before it, f its frequency and w its width.
How do I find the median class? Work out n/2, then find the first class whose cumulative frequency is at least n/2.
Can I use the same formula for quartiles and percentiles? Yes. Use n/4 for Q1, 3n/4 for Q3 and k × n / 100 for the k-th percentile in place of n/2.
Why is the grouped median only an estimate? The formula assumes values are spread evenly within the class. Real data is rarely perfectly even, so the true median of the raw values can differ a little.