Median, Quartiles and Interquartile Range

AS · S1 · 14 min

The median is the middle value when the data are put in order, and the quartiles cut the data into quarters. Together they describe a data set in a way that ignores a few extreme values: the median is the typical value, and the interquartile range measures how spread out the middle half is. The syllabus lists median, range and interquartile range among the measures you must "understand and use", and they appear in nearly every Paper 5 data question: from raw lists, stem-and-leaf diagrams, frequency tables and cumulative frequency graphs.

The median

Definition

The median is the middle value of the data when arranged in order of size. For nn ordered values it is the n+12\tfrac{n+1}{2}th value. When nn is even this position is a half, and the median is the mean of the two middle values.

  • n=9n = 9: the 55th value.
  • n=10n = 10: halfway between the 55th and 66th values.

The position formula gives where the median is, not what it is. A common slip is to write "median =5.5= 5.5" when 5.55.5 was the position.

Quartiles

The median splits the data into a lower half and an upper half. The quartiles are the medians of those halves.

Definition
  • The lower quartile Q1Q_1 is the median of the lower half of the ordered data.
  • The upper quartile Q3Q_3 is the median of the upper half.
  • When nn is odd, the median itself belongs to neither half.
  • The interquartile range is IQR=Q3−Q1\text{IQR} = Q_3 - Q_1.
  • The range is the largest value minus the smallest value.
Key result
nnMedianLower halfQ1Q_1Q3Q_3
111166thvalues 11–5533rd99th
1212mean of 66th, 77thvalues 11–66mean of 33rd, 44thmean of 99th, 1010th
151588thvalues 11–7744th1212th
1616mean of 88th, 99thvalues 11–88mean of 44th, 55thmean of 1212th, 1313th
2020mean of 1010th, 1111thvalues 11–1010mean of 55th, 66thmean of 1515th, 1616th
Tip

Textbooks differ slightly on quartiles for small data sets (some use the n+14\tfrac{n+1}{4}th value with interpolation). The halves method above is clear and widely accepted for Paper 5; whatever method you use, state the positions so the examiner can follow you. For large grouped data sets the question will expect a cumulative frequency graph, where these small differences vanish.

Why the IQR and not just the range

The range depends on only two values, the two most extreme, so a single unusual value can make it enormous. The IQR describes the spread of the middle 50%50\% of the data, so it ignores the top and bottom quarters, where outliers live. The IQR goes naturally with the median; the standard deviation goes naturally with the mean.

Percentiles

The kkth percentile is the value below which k%k\% of the data lie. The lower quartile is the 2525th percentile, the median the 5050th and the upper quartile the 7575th. Percentiles are almost always estimated from a cumulative frequency graph, at cumulative frequency k100n\tfrac{k}{100}n. The interval between the 1010th and 9090th percentiles (the 1010 to 9090 interpercentile range) contains the middle 80%80\% of the data.

The median of a frequency table

When discrete data are given in a frequency table, you cannot see the ordered list, but you can find any position using cumulative frequencies.

Method
  1. Add a running total (cumulative frequency) column.
  2. Work out the position(s) needed: n+12\tfrac{n+1}{2} for the median; the middle of each half for the quartiles.
  3. The value at a position is the first value whose cumulative frequency reaches that position.

The median of grouped data

For grouped data, the median is estimated from a cumulative frequency graph at n2\tfrac{n}{2}, or calculated by linear interpolation:

median≈L+n2−Ff×w,\text{median} \approx L + \frac{\tfrac{n}{2} - F}{f} \times w,

where LL is the lower boundary of the class containing the median, FF the cumulative frequency before that class, ff its frequency and ww its width. Full method and examples are in Cumulative frequency graphs.

Properties of the median

  • It is not affected by extreme values: making the largest value ten times larger leaves the median unchanged.
  • It is a good average for skewed data or data with outliers.
  • It does not use the actual size of every value, only their order, so it uses less information than the mean.
  • Two medians cannot be combined to give the median of the combined data (unlike means, which combine through totals).

Worked examples

Median and quartiles of raw data (routine)

Find the median, quartiles and interquartile range of:

12, 15, 9, 22, 18, 11, 25, 14, 19, 1612,\ 15,\ 9,\ 22,\ 18,\ 11,\ 25,\ 14,\ 19,\ 16
Solution

Ordered: 9,11,12,14,15,16,18,19,22,259, 11, 12, 14, 15, 16, 18, 19, 22, 25. n=10n = 10.

Median: halfway between the 55th and 66th values, 15+162=15.5\tfrac{15 + 16}{2} = 15.5.

Lower half: 9,11,12,14,159, 11, 12, 14, 15, so Q1=12Q_1 = 12. Upper half: 16,18,19,22,2516, 18, 19, 22, 25, so Q3=19Q_3 = 19.

IQR=19−12=7\text{IQR} = 19 - 12 = 7. (Range =25−9=16= 25 - 9 = 16.)

Median from a frequency table

The numbers of children in 5050 families:

Number of children001122334455
Frequency6611111414997733

Find the median and the interquartile range.

Solution

Cumulative frequencies: 6,17,31,40,47,506, 17, 31, 40, 47, 50.

n=50n = 50: the median is halfway between the 2525th and 2626th values. Values 1818 to 3131 are all 22, so both are 22: median =2= 2.

Lower half: values 11 to 2525. Its median is the 1313th value. Values 77 to 1717 are 11, so Q1=1Q_1 = 1.

Upper half: values 2626 to 5050. Its median is the 1313th of these, i.e. the 3838th value overall. Values 3232 to 4040 are 33, so Q3=3Q_3 = 3.

IQR=3−1=2\text{IQR} = 3 - 1 = 2 children.

Effect of an extreme value

The times, in seconds, for 1313 swimmers are:

31, 28, 35, 40, 26, 33, 29, 38, 30, 27, 36, 32, 9531,\ 28,\ 35,\ 40,\ 26,\ 33,\ 29,\ 38,\ 30,\ 27,\ 36,\ 32,\ 95

(a) Find the mean and the median. (b) The 9595 is found to belong to a swimmer who stopped mid-race, and is removed. Find the new mean and median. (c) Which average was more representative of the original data? Explain.

Solution

(a) ∑x=480\sum x = 480, so the mean is 48013=36.9\tfrac{480}{13} = 36.9 s (3 s.f.). Ordered: 26,27,28,29,30,31,32,33,35,36,38,40,9526, 27, 28, 29, 30, 31, 32, 33, 35, 36, 38, 40, 95. The median is the 77th value, 3232 s.

(b) Without 9595: ∑x=385\sum x = 385 for 1212 values, mean =32.1= 32.1 s (3 s.f.). Median: halfway between the 66th and 77th, 31+322=31.5\tfrac{31 + 32}{2} = 31.5 s.

(c) The median. In (a), 1212 of the 1313 times are 4040 s or less, yet the mean (36.936.9 s) is larger than all but two of the times, because the single extreme value pulls it up. The median (3232 s) barely changes when the extreme value is removed.

An unknown frequency and the median (exam-hard)

The scores of some students are shown.

Score1122334455
Frequency4477kk6633

Given that the median score is 33, find the smallest possible value of kk.

Solution

n=20+kn = 20 + k. The first 1111 values are 11 or 22; the scores of 33 occupy positions 1212 to 11+k11 + k.

The median is 33 when the middle position (or both middle positions, if nn is even) lies in positions 1212 to 11+k11 + k.

Try small values:

  • k=1k = 1: n=21n = 21, median is the 1111th value, which is 22. No.
  • k=2k = 2: n=22n = 22, median is the mean of the 1111th and 1212th values, 2+32=2.5\tfrac{2 + 3}{2} = 2.5. No.
  • k=3k = 3: n=23n = 23, median is the 1212th value, which is 33. Yes.

For larger kk the middle position stays within the block of 33s, so the smallest value is k=3k = 3.

Reconstructing a data set (exam-hard)

Five positive integers have median 66, mean 77, a single mode 44, and range 99. Find the five integers.

Solution

Write them in order a≤b≤c≤d≤ea \le b \le c \le d \le e. The median is c=6c = 6.

The mode is 44, and 4<64 < 6, so 44 must appear at least twice among a,ba, b: a=b=4a = b = 4. Then dd and ee must be different from each other (otherwise there would be a second mode).

Range: e−a=9e - a = 9, so e=13e = 13. Mean: the total is 5×7=355 \times 7 = 35, so d=35−4−4−6−13=8d = 35 - 4 - 4 - 6 - 13 = 8.

The integers are 4,4,6,8,134, 4, 6, 8, 13. Check: the mode is 44 alone, the median is 66, the mean is 77 and the range is 99.

Watch out

Using n+12\tfrac{n+1}{2} for a cumulative frequency graph. For raw data and frequency tables use positions (n+12\tfrac{n+1}{2}th value). For a cumulative frequency graph of grouped data read at n2\tfrac{n}{2}.

Watch out

Not ordering the data first. The median of 12,15,9,22,1812, 15, 9, 22, 18 is not 99 (the middle of the list as written); it is 1515, the middle of 9,12,15,18,229, 12, 15, 18, 22.

Watch out

Reading the frequency, not the value. In a frequency table, the median is a value of the variable (number of children), never a frequency or a cumulative frequency.

Exam tip
  • State the positions: "n=50n = 50, so the median is the mean of the 2525th and 2626th values". It earns the method mark even if you misread the table.
  • For grouped data say "estimate". For raw data the median is exact.
  • When asked for "a measure of spread" to go with the median, give the IQR. When asked to compare, quote both groups' values.
  • Questions that say "explain why the median might be preferred to the mean" want: the data contain an extreme value (or are skewed), which affects the mean but not the median.
Summary
  • Median: the n+12\tfrac{n+1}{2}th ordered value; mean of the two middle values when nn is even.
  • Q1Q_1, Q3Q_3: medians of the lower and upper halves (exclude the median when nn is odd).
  • IQR=Q3−Q1\text{IQR} = Q_3 - Q_1, the spread of the middle 50%50\%; range == largest −- smallest.
  • Frequency tables: use cumulative frequencies to locate positions.
  • Grouped data: estimate from a cumulative frequency graph at n2\tfrac{n}{2}, n4\tfrac{n}{4}, 3n4\tfrac{3n}{4}.
  • The median and IQR are not affected by extreme values; use them for skewed data or data with outliers.

Practice questions

Question
  1. Find the median and interquartile range of 7,3,9,12,5,8,10,4,67, 3, 9, 12, 5, 8, 10, 4, 6.
  2. Find the median and interquartile range of 2.4,3.1,1.8,2.9,3.5,2.2,4.0,2.62.4, 3.1, 1.8, 2.9, 3.5, 2.2, 4.0, 2.6.
  3. The shoe sizes of 4040 people are: size 44 (22 people), 55 (55), 66 (99), 77 (1111), 88 (77), 99 (44), 1010 (22). Find the median and interquartile range.
  4. For the shoe sizes in question 3, calculate the mean and say whether the mean, median or mode would be most useful to a shoe shop deciding which size to stock most of.
  5. The masses of 6060 parcels are grouped as 0≤m<20 \le m < 2 (1212), 2≤m<42 \le m < 4 (2020), 4≤m<84 \le m < 8 (1818), 8≤m<128 \le m < 12 (1010) (kg). Estimate the median mass by linear interpolation.
  6. The salaries of the 99 employees of a small company are (in thousands of dollars): 18,20,21,21,23,24,26,28,15018, 20, 21, 21, 23, 24, 26, 28, 150. Find the mean and the median, and explain which better represents a typical salary.
  7. The numbers of pets owned by some families are shown: 00 pets (55 families), 11 (99), 22 (88), 33 (kk), 44 (44). The median number of pets is 22. Find the set of possible values of kk.
  8. Seven integers have mean 1010, median 99, a single mode 77, range 1212, smallest value 55 and interquartile range 88. Find the seven integers.
Answers
  1. Ordered: 3,4,5,6,7,8,9,10,123, 4, 5, 6, 7, 8, 9, 10, 12; n=9n = 9. Median == 55th =7= 7. Lower half 3,4,5,63, 4, 5, 6: Q1=4.5Q_1 = 4.5. Upper half 8,9,10,128, 9, 10, 12: Q3=9.5Q_3 = 9.5. IQR =5= 5.

  2. Ordered: 1.8,2.2,2.4,2.6,2.9,3.1,3.5,4.01.8, 2.2, 2.4, 2.6, 2.9, 3.1, 3.5, 4.0; n=8n = 8. Median =2.6+2.92=2.75= \tfrac{2.6 + 2.9}{2} = 2.75. Q1=2.2+2.42=2.3Q_1 = \tfrac{2.2 + 2.4}{2} = 2.3. Q3=3.1+3.52=3.3Q_3 = \tfrac{3.1 + 3.5}{2} = 3.3. IQR =1.0= 1.0.

  3. Cumulative frequencies: 2,7,16,27,34,38,402, 7, 16, 27, 34, 38, 40. Median: mean of the 2020th and 2121st values, both size 77, so the median is 77. Q1Q_1: median of values 11 to 2020, mean of the 1010th and 1111th, both 66, so Q1=6Q_1 = 6. Q3Q_3: median of values 2121 to 4040, mean of the 3030th and 3131st, both 88, so Q3=8Q_3 = 8. IQR =2= 2.

  4. ∑fx=8+25+54+77+56+36+20=276\sum fx = 8 + 25 + 54 + 77 + 56 + 36 + 20 = 276, so the mean is 27640=6.9\tfrac{276}{40} = 6.9. The mode (size 77) is the most useful: the shop wants the size most people take, and 6.96.9 is not a shoe size.

  5. n=60n = 60, so read at 3030. Cumulative frequencies 12,32,50,6012, 32, 50, 60; 3030 lies in 2≤m<42 \le m < 4: median ≈2+30−1220×2=3.8 kg\approx 2 + \tfrac{30 - 12}{20} \times 2 = 3.8\ \text{kg}.

  6. ∑x=331\sum x = 331, mean =3319=36.8= \tfrac{331}{9} = 36.8 thousand dollars (3 s.f.). Median == 55th value =23= 23 thousand dollars. The median: the one very large salary (150150) pulls the mean above eight of the nine salaries, while the median is unaffected.

  7. n=26+kn = 26 + k. Positions: 00s are 11–55, 11s are 66–1414, 22s are 1515–2222, then 33s are 2323 to 22+k22 + k. The median is 22 when the middle position(s) lie in 1515–2222. If nn is odd the median is the 27+k2\tfrac{27 + k}{2}th value: need 15≤27+k2≤2215 \le \tfrac{27 + k}{2} \le 22, i.e. 3≤k≤173 \le k \le 17. If nn is even both the 26+k2\tfrac{26 + k}{2}th and the next value must be in 1515–2222: need 26+k2≥15\tfrac{26 + k}{2} \ge 15 and 26+k2+1≤22\tfrac{26 + k}{2} + 1 \le 22, i.e. 4≤k≤164 \le k \le 16. Combining (and checking k=2k = 2 gives median 1.51.5 and k=18k = 18 gives 2.52.5): 3≤k≤173 \le k \le 17.

  8. In order: 5,b,c,9,e,f,g5, b, c, 9, e, f, g. Range 1212 gives g=17g = 17. The only values below the median are 55, bb and cc, and 77 must appear at least twice, so b=c=7b = c = 7. With n=7n = 7, Q1Q_1 is the 22nd value (77) and Q3Q_3 the 66th (ff), so f−7=8f - 7 = 8 and f=15f = 15. The total is 7×10=707 \times 10 = 70, so e=70−(5+7+7+9+15+17)=10e = 70 - (5 + 7 + 7 + 9 + 15 + 17) = 10. The integers are 5,7,7,9,10,15,175, 7, 7, 9, 10, 15, 17. Check: ascending order, only 77 repeats, median 99, mean 1010, range 1212, IQR 88.

How well do you know this?

Builds on

Where this leads

Console

Search notes, courses and tools, or run an action