Why Quartiles Need a Consistent Rule
The median identifies the middle of an ordered data set. Quartiles extend that idea: the first quartile marks the middle of the lower part of the data, and the third quartile marks the middle of the upper part. To calculate them, we must first decide exactly which observations belong to each part. This tutorial uses the median-of-halves method: sort the observations, divide them into lower and upper halves, and take the median of each half.
The method is straightforward once the halves are formed correctly. The main detail is what to do when the full data set has an odd number of observations. In that case, the overall median is left out of both halves. For an even-sized data set, the observations divide into two equal halves without leaving a single middle observation between them.
A Step-by-Step Calculation
Use the following sequence for any data set with at least two observations. The ordering is essential: the halves are formed by the observations’ positions in the ordered list, not by their original order or by the size of the gaps between their values.
Write the data from smallest to largest. Repeated values remain in the list and each counts as an observation.
If \(n\) is even, place the first \(n/2\) observations in the lower half and the last \(n/2\) in the upper half. If \(n\) is odd, set aside the overall median and use the observations below it for the lower half and above it for the upper half.
The lower-half median is \(Q_1\); the upper-half median is \(Q_3\). If a half has an even number of observations, average its two middle values.
For clarity, write the ordered observations as \(x_{(1)},x_{(2)},\ldots,x_{(n)}\), where \(x_{(1)}\) is the smallest and \(x_{(n)}\) the largest. When \(n=2m\), each half contains \(m\) observations. The lower half consists of \(x_{(1)},\ldots,x_{(m)}\), and the upper half consists of \(x_{(m+1)},\ldots,x_{(2m)}\). When \(n=2m+1\), with \(m\geq 1\), the overall median is \(x_{(m+1)}\); the lower half is \(x_{(1)},\ldots,x_{(m)}\), and the upper half is \(x_{(m+2)},\ldots,x_{(2m+1)}\).
Worked Examples
Worked Example: Quartiles for an Even-Sized Data Set
A hypothetical group of eight packages has recorded masses, in grams, of \(15, 4, 22, 9, 18, 6, 12,\) and \(7\). Find \(Q_1\) and \(Q_3\) by the median-of-halves method.
Order the observations: \(4, 6, 7, 9, 12, 15, 18, 22\). Here \(n=8\), so split the list into two groups of four:
Each half has an even number of observations, so take the mean of its two middle values. In the lower half those values are \(6\) and \(7\); in the upper half they are \(15\) and \(18\).
By this method, the first quartile is \(6.5\) g and the third quartile is \(16.5\) g. The units remain grams because the quartiles are values on the original measurement scale.
Worked Example: Quartiles for an Odd-Sized Data Set
A hypothetical set of nine waiting times, in minutes, is \(14, 3, 20, 8, 26, 12, 5, 17,\) and \(10\). Find both quartiles using the median-of-halves method.
Order the observations: \(3, 5, 8, 10, 12, 14, 17, 20, 26\). Since \(n=9\), the fifth observation, \(12\), is the overall median. Exclude it from both halves:
Both halves contain four observations, so each half’s median is the mean of its two middle values. For the lower half, these values are \(5\) and \(8\); for the upper half, they are \(17\) and \(20\).
Thus \(Q_1=6.5\) minutes and \(Q_3=18.5\) minutes. The value \(12\) was not included in either quartile calculation because it was the overall median.
Worked Example: Odd Number of Observations and Repeated Values
A hypothetical data set contains seven daily counts: \(8, 2, 14, 2, 11, 5,\) and \(2\). Find \(Q_1\) and \(Q_3\).
Order the observations: \(2, 2, 2, 5, 8, 11, 14\). The overall median is the fourth observation, \(5\). Excluding it leaves three observations in each half:
Each half has three observations, so its median is its middle observation. The middle value of the lower half is \(2\), and the middle value of the upper half is \(11\). Therefore,
The repeated \(2\)s are all retained: each is a recorded observation and occupies its own position in the ordered list. The method does not remove duplicates.
Why the Odd-Sample Rule Works
The division into halves follows the positions of observations around the center of the ordered data. For \(n=2m\), there are \(m\) observations on each side of the division between positions \(m\) and \(m+1\). For \(n=2m+1\), there are \(m\) observations below the central position \(m+1\) and \(m\) above it. Setting aside the overall median leaves the same number of observations in the lower and upper halves.
The quartiles are then the centers of those halves. This can be checked by looking at the middle positions within each half. For example, with \(n=2m+1\) and \(m\geq1\), the lower half contains exactly positions \(1\) through \(m\), while the upper half contains positions \(m+2\) through \(2m+1\). Taking each half’s median therefore locates its center without reusing the overall median.
If a half has an even number of observations, there is no single observation exactly in its center. Averaging the two central values gives the median of that half, following the same even-sized median rule. This is why a quartile can fall between two observed values, as in the first two examples.
Small Samples and Checks
The procedure requires care at the smallest sample sizes. With two observations, the lower and upper halves each contain one observation, so \(Q_1\) is the smaller value and \(Q_3\) is the larger value. With three observations, excluding the overall median leaves one observation in each half; those two remaining values are \(Q_1\) and \(Q_3\).
With one observation, the overall median is the only observation. Excluding it leaves two empty halves, and an empty set has no median. Therefore, the median-of-halves method does not define \(Q_1\) or \(Q_3\) for a one-observation data set. Do not apply the odd-sample rule with \(m=0\); that would ask for the medians of empty halves.
After calculating, check that the data were sorted, each observation was assigned correctly, and the quartiles lie in the original units. In a nondecreasing ordered list, the resulting values should satisfy \(Q_1\leq Q_3\). If this check fails, revisit the ordering and the halves before changing any calculations.
Common Mistake: Keeping the Overall Median in Both Halves
A frequent error for odd-sized data is to put the overall median into both the lower and upper halves. For the nine waiting times above, that would make the lower group \(3,5,8,10,12\) and the upper group \(12,14,17,20,26\). This does not follow the median-of-halves method because the overall median has been counted in both groups. The correction is to set aside \(12\), leaving \(3,5,8,10\) and \(14,17,20,26\).
Another error is to split the original, unsorted list by its first and last entries or to discard repeated values. Quartiles depend on the ordered positions of all observations. Sort first, keep every recorded value, and then form the halves.
Check Your Understanding
Use the median-of-halves method for each question. Keep all observations, including ties.
- For the ordered data \(2, 4, 6, 8, 10, 12\), identify the lower and upper halves and calculate \(Q_1\) and \(Q_3\).
- For the ordered data \(1, 3, 5, 7, 9, 11, 13\), which observation is excluded from the halves? Calculate both quartiles.
- A learner sorts \(2, 6, 2, 9, 4\) as \(2, 2, 4, 6, 9\), then uses \(2,2,4\) as the lower half and \(4,6,9\) as the upper half. What is wrong with this split?
- What quartiles does the median-of-halves method give for the two observations \(5\) and \(13\)?
- Why does this method not define quartiles for a data set containing only one observation?