Quartiles describe positions within an ordered dataset. The first quartile, median and third quartile locate its lower, middle and upper portions. The interquartile range, or IQR, subtracts the first quartile from the third and summarises the spread of the central part of the data.

For finite datasets, quartile algorithms are not universal. A calculator and a classroom method can return different values while both implement stated conventions correctly. This page fixes one convention and uses it consistently in the companion box-plot and outlier lessons.

On this page

The convention used in this set

Sort the observations in ascending order. Find the median. Split the data into lower and upper halves; if the sample size is odd, exclude the overall median from both halves. The median of the lower half is Q1Q_1 and the median of the upper half is Q3Q_3.

This is the median-of-halves convention with the overall median excluded when necessary. It applies to the teaching lists here, which have at least four observations. Other resources or software may interpolate percentiles differently. Always report the method when a numerical difference matters.

Statistics Canada’s quartile introduction develops ordered-data measures of spread. The explicit algorithm above is the convention selected for the CTS examples, not a claim that every source uses it.

Work through an even-sized dataset

Use the ten synthetic journey times, in minutes:

8,10,12,12,14,16,18,20,22,48.8,\ 10,\ 12,\ 12,\ 14,\ 16,\ 18,\ 20,\ 22,\ 48.

The median averages the fifth and sixth observations:

Q2=14+162=15.Q_2=\frac{14+16}{2}=15.

The lower half is 8,10,12,12,148,10,12,12,14, whose median is 12. The upper half is 16,18,20,22,4816,18,20,22,48, whose median is 20. Therefore

Q1=12,Q2=15,Q3=20,Q_1=12,\qquad Q_2=15,\qquad Q_3=20,

and

IQR=Q3−Q1=20−12=8 minutes.\operatorname{IQR}=Q_3-Q_1=20-12=8\text{ minutes}.

The IQR is a difference, so its unit is the original unit. It is not Q3/Q1Q_3/Q_1 and is not the entire range, which here is 48−8=4048-8=40 minutes.

Quartiles locate the middle half of the ordered data

Split the ordered data into halvesTen sorted observations are split into two halves of five. Their medians are 12 and 20, and the overall median is 15.8101212141618202248Lower halfUpper halfQ₁ = 12Q₃ = 20Median = (14 + 16) ÷ 2 = 15IQR = 20 − 12 = 8 minutes
Synthetic journey times, n = 10. The median-of-halves convention is used throughout this set.
Diagram explanation and exact data

The lower five values are 8, 10, 12, 12 and 14; the upper five are 16, 18, 20, 22 and 48. Their medians are 12 and 20. The overall median is the average of the fifth and sixth values.

Quartiles locate the middle half of the ordered data: exact reference data
Position Value Half
1 8 Lower
2 10 Lower
3 12 Lower
4 12 Lower
5 14 Lower
6 16 Upper
7 18 Upper
8 20 Upper
9 22 Upper
10 48 Upper

Work through an odd-sized dataset

For the illustrative list 2,3,4,6,8,9,122,3,4,6,8,9,12, the overall median is 6. Exclude it from both halves. The lower half is 2,3,42,3,4 and the upper half is 8,9,128,9,12. Thus

Q1=3,Q2=6,Q3=9,IQR=6.Q_1=3,\qquad Q_2=6,\qquad Q_3=9,\qquad\operatorname{IQR}=6.

For comparison, an interpolation rule can place the ppth quantile at position h=1+(n−1)ph=1+(n-1)p in the sorted list. With n=7n=7, the positions for p=0.25p=0.25 and p=0.75p=0.75 are 2.5 and 5.5. Interpolating halfway between the neighbouring observations gives (3+4)/2=3.5(3+4)/2=3.5 and (8+9)/2=8.5(8+9)/2=8.5, with IQR 5. The records have not changed; the definition of the sample quantile has.

Do not mix quartiles from one algorithm with a box plot or answer key calculated using another without explaining the difference.

What “the middle 50%” means

Quartiles are intended to locate quarter divisions of a distribution. For a finite sample with ties, saying that exactly 25% of observations are strictly below Q1Q_1 is often false.

In the journey-time example, two observations are below 12, but four are at or below 12. That is 20% strictly below and 40% at or below, not a contradiction. Two observations share the quartile value.

The interval from Q1Q_1 to Q3Q_3 describes the central spread in the selected convention. It should not be interpreted as a probability guarantee for a new individual or as a confidence interval for a population parameter.

Compare range and IQR

The range responds directly to the minimum and maximum. The IQR depends on the central order statistics. If the largest journey time changes from 48 to 80, the range becomes 80−8=7280-8=72 minutes, while Q1Q_1, Q3Q_3 and the IQR remain 12, 20 and 8.

This resistance to one extreme change is useful for skewed data. It does not mean the IQR records everything important about the tails. A report might include the median and IQR together with a plot and a note about unusually long journeys.

Adding the same constant to every value shifts both quartiles by that constant but leaves the IQR unchanged. Multiplying all values by a positive factor multiplies the quartiles and the IQR by that factor. With a negative factor, order reverses; the new lower quartile comes from the old upper quartile.

Use fences as a screening rule

A common descriptive rule places inner fences at

L=Q1−1.5IQR,U=Q3+1.5IQR.L=Q_1-1.5\operatorname{IQR},\qquad U=Q_3+1.5\operatorname{IQR}.

For the journey times,

L=12−1.5(8)=0,U=20+1.5(8)=32.L=12-1.5(8)=0,\qquad U=20+1.5(8)=32.

The value 48 is strictly above 32, so the rule flags it. The number 32 is a fence, not an observed journey time. In the modified box plot used in this set, the upper whisker ends at 22, the largest observed value still within the fence.

An observation exactly on a fence is not flagged by the strict “beyond the fence” rule. A flagged value is not automatically erroneous. Outliers explains how to investigate it.

Quartiles in grouped data and reports

Exact sample quartiles generally cannot be recovered from broad histogram bins alone. A bin can tell you that a central observation lies between two boundaries without identifying its precise value. Estimates based on interpolation within bins need additional assumptions.

When comparing published IQRs, check the variable, unit, population, sample size and quantile convention. Weighted survey quantiles can also differ from unweighted quantiles calculated directly from the responding records.

Practice questions

  1. Using this page’s convention, find Q1Q_1, the median, Q3Q_3 and the IQR for 2,3,4,6,8,9,122,3,4,6,8,9,12.
  2. With Q1=12Q_1=12 and Q3=20Q_3=20, calculate the 1.5 IQR fences.
  3. Does a value exactly equal to the upper fence count as an outlier under this set’s rule?
Check your answers
  1. Exclude the median 6 from the halves. Their medians are 3 and 9, giving Q1=3Q_1=3, Q2=6Q_2=6, Q3=9Q_3=9 and IQR 6.
  2. The IQR is 8. The fences are 12−12=012-12=0 and 20+12=3220+12=32.
  3. No. The rule flags values strictly below the lower fence or strictly above the upper fence. It is a screening convention, not a test that establishes data error.

Related topics

Box Plots turns these summaries into a display. Outliers develops the investigation process, while Mean, Median and Mode helps choose a complementary measure of centre.

Sources and further reading