Median of grouped data

Line up a class of fifty students by height and the middle student's height is the median — the value that splits the data exactly in half, immune to a single freakishly tall or short outlier. That is easy when you can see every individual value. But real data usually arrives already bucketed into class intervals — marks grouped as 00–1010, 1010–2020, and so on — and once the individual values are lost inside a bucket, you cannot simply "pick the middle one." You need a systematic way to track how many observations have piled up by the end of each class, spot the class that contains the middle position, and then estimate exactly where inside that class the median falls. This article builds that machinery: the cumulative frequency table, the median class, and the formula that locates the median within it — the same class-interval setup you already used for mean and mode of grouped data.

The core insight

Build a cumulative frequency table, find the class where the running total first reaches or passes n/2n/2, and use the median formula to pinpoint the median inside that class.

The core idea

Grouped data hides individual values inside class intervals, so the median cannot be read off directly — it has to be located using running totals.

Cumulative frequency (cf). For a grouped frequency distribution, the cumulative frequency of a class is the sum of all frequencies up to and including that class. It answers the question "how many observations lie at or below the upper limit of this class?" Building this column is always the first step, and it must be done in order, class by class, adding each new frequency to the running total.

The median class. Let n=∑fin = \sum f_i be the total number of observations across all classes. The middle position in the data lies at n/2n/2. Scan the cumulative frequency column from the top and find the first class whose cf is greater than or equal to n/2n/2 — this is the median class, the interval that actually contains the middle observation.

Locating the median inside the class. Once the median class is known, four quantities from it feed into the median formula:

  • ll = lower limit of the median class
  • nn = total number of observations
  • cfcf = cumulative frequency of the class immediately before the median class (not the median class's own cf)
  • ff = frequency of the median class (not cumulative)
  • hh = class width (size) of the median class

The formula assumes the ff observations inside the median class are spread evenly across its width, so it interpolates proportionally from the class's lower limit:

Median=l+(n2−cff)×h\text{Median} = l + \left(\frac{\dfrac{n}{2} - cf}{f}\right)\times h

where: ll, nn, cfcf, ff, hh are as defined above, all read from the cumulative frequency table once the median class is identified. This formula requires the class intervals to be continuous (like 1010–2020, 2020–3030, with no gaps) and, ideally, of equal width.

Figure
A cumulative frequency staircase rising with class intervals along the bottom axis and a horizontal line at n over 2 crossing the step that marks the median class
Cumulative frequency rises in steps — the median class is where it crosses n over 2 class intervals cumulative frequency n over 2 = 25 median class 20 to 30 0-10 10-20 20-30 30-40 40-50
Derivation ALocating the median inside a class

The goal is to justify why the median formula uses l+(n/2−cff)×hl + \left(\dfrac{n/2 - cf}{f}\right)\times h rather than simply reporting the median class itself, showing that the extra term is a proportional interpolation that assumes the ff observations of the median class are spread evenly across its width hh, and that it correctly reduces to the class boundary when the target position sits right at the edge.

Step 1. Set up the picture. The median class starts at ll and has cfcf observations already counted before it begins (from all earlier classes) and ff more observations spread across it, ending at cumulative total cf+fcf + f. The target position we want to reach is n/2n/2.

Step 2. Find how far into the median class the target lies, in observation-count terms. Since cfcf observations are already done before this class starts, the number of this class's own observations still needed to reach n/2n/2 is n2−cf\dfrac{n}{2} - cf.

Step 3. Convert that count into a fraction of the class. The median class holds ff observations spread across width hh, so each observation is assumed to occupy an equal share h/fh/f of the width. The fraction of the class we must travel is therefore n/2−cff\dfrac{n/2 - cf}{f}, and the actual distance travelled from ll is that fraction multiplied by the full width: (n/2−cff)×h\left(\dfrac{n/2-cf}{f}\right)\times h.

Step 4. Add this distance to the starting point ll to land on the median: Median=l+(n/2−cff)×h\text{Median} = l + \left(\dfrac{n/2-cf}{f}\right)\times h. Check the edge case: if n/2=cfn/2 = cf exactly, the fraction is zero and the median equals ll, the class's own lower limit — exactly right, since the target position was reached at the very start of this class. If n/2=cf+fn/2 = cf + f, the fraction is 11 and the median lands at l+hl + h, the class's upper limit — again correct, since the target was reached only at the very end of the class.

Worked example

Find the median of the following frequency distribution. Class intervals: 00–1010, 1010–2020, 2020–3030, 3030–4040, 4040–5050 with frequencies 55, 88, 1515, 1616, 66 respectively.

Step 1. Build the cumulative frequency table by adding each frequency to the running total: cf values are 55, 1313, 2828, 4444, 5050 for the five classes in order.

Step 2. Find nn and n/2n/2. The total is n=5+8+15+16+6=50n = 5+8+15+16+6 = 50, so n2=25\dfrac{n}{2} = 25.

Step 3. Locate the median class. Scanning the cf column, the first entry that is ≥25\geq 25 is 2828, which belongs to the class 2020–3030. So the median class is 2020–3030.

Step 4. Identify the terms from the table: l=20l = 20 (lower limit of 2020–3030), cf=13cf = 13 (the cumulative frequency of the class before it, namely 1010–2020), f=15f = 15 (frequency of 2020–3030 itself), and h=10h = 10 (class width).

Step 5. Apply the formula. Median=20+(25−1315)×10=20+(1215)×10=20+8=28\text{Median} = 20 + \left(\dfrac{25-13}{15}\right)\times 10 = 20 + \left(\dfrac{12}{15}\right)\times 10 = 20 + 8 = 28. The median of the distribution is 28.

Competitive stretch

The daily wages (in ₹) of 6060 workers are grouped as: 100100–120120, 120120–140140, 140140–160160, 160160–180180, 180180–200200 with worker counts 1010, 1515, 2020, 88, 77.

Step 1. Cumulative frequencies: 1010, 2525, 4545, 5353, 6060.

Step 2. n=60n = 60, so n/2=30n/2 = 30. The first cf ≥30\geq 30 is 4545, in class 140140–160160, so that is the median class.

Step 3. Here l=140l = 140, cf=25cf = 25 (from the class before), f=20f = 20, h=20h = 20. So Median=140+(30−2520)×20=140+(520)×20=140+5=145\text{Median} = 140 + \left(\dfrac{30-25}{20}\right)\times 20 = 140 + \left(\dfrac{5}{20}\right)\times 20 = 140+5 = 145. The median daily wage is ₹145.

Common traps

  • Using the cf of the median class itself instead of the class immediately before it — cfcf in the formula always belongs to the previous class.
  • Skipping straight to the class with the highest frequency instead of scanning cf for the first value ≥n/2\geq n/2 — that mistake finds the mode's class, not the median's.
  • Swapping ff and cfcf: ff is the plain (non-cumulative) frequency of the median class, while cfcf is the running total up to the class before it.
  • Applying the formula to non-continuous class intervals (like inclusive-type 11–1010, 1111–2020) without first converting them to continuous form.

Ask the tutor: Want to try a median problem where the class widths are unequal or the data needs converting to continuous intervals first — ask the AI tutor to walk through one with you.

Why do we use cf of the previous class and not the median class itself?

The formula measures how many more observations, beyond what earlier classes already contributed, are needed inside the median class to reach the halfway mark n/2n/2. That "needed" count is n/2n/2 minus everything already counted before the median class starts, which is exactly the previous class's cf. Using the median class's own cf would double count part of its own frequency and give a wrong, usually smaller, interpolation distance.

What if two classes tie for the first cf reaching n over 2?

That cannot actually happen for a single class boundary, because cf strictly increases (or stays flat only if a frequency is zero) as you move down the table — each new cf equals the previous cf plus that class's own frequency. The "first class whose cf is greater than or equal to n/2" is always uniquely determined by scanning top to bottom and stopping at the very first class that satisfies the condition.

Does the median formula work if the class widths are different?

The formula as given assumes the median class has a well-defined width hh that you plug in directly, and it works correctly even if other classes in the table have different widths — only the width of the median class itself enters the formula. What it does require is that class intervals be continuous, with no gaps between the upper limit of one class and the lower limit of the next; inclusive-type intervals must be converted to continuous form first.

Before this

Where this leads