Tutorials › Introduction to Statistics › Quartile Conventions in Hand Calculations and Software

Center, Spread and Position · Tutorial 152 of 996

Quartile Conventions in Hand Calculations and Software

Learn to calculate quartiles using the median of halves and common interpolation rules, and to identify why different tools can report different values for the same data.

Beginner 10 min read

What You'll Learn

  • Define quartiles using an explicitly stated convention
  • Calculate quartiles by taking medians of the lower and upper halves
  • Use interpolation to calculate quartiles from fractional data positions
  • Compare two common interpolation rules with the median-of-halves method
  • Explain why software can report different quartiles for identical data
  • Check that quartile calculations use sorted observations and consistent arithmetic

Why Quartile Methods Can Disagree

Quartiles describe positions within an ordered data set, but a small data set does not always contain observations exactly at the 25th and 75th percentiles. A calculation must then follow a convention: it might take medians of groups of observations, or interpolate between observations at nearby positions. Both approaches are used in practice, so two correct calculations can differ if they use different conventions.

The important habit is to identify the rule before calculating. A reported quartile is not fully specified by a number alone when the method is unknown. This matters when checking hand calculations, comparing software output, or reproducing a summary from another source.

Definition: For ordered observations \(x_{(1)} \leq x_{(2)} \leq \cdots \leq x_{(n)}\), the first quartile \(Q_1\) and third quartile \(Q_3\) are values intended to mark the lower and upper quarter positions of the data. In a finite data set, their exact calculated values depend on the quartile convention used. A quartile convention specifies how to choose or calculate those values from the ordered observations.

The notation \(x_{(i)}\) means the observation in position \(i\) after sorting the data from smallest to largest. The order is essential: positions refer to the sorted list, not to the order in which measurements happened to be recorded. The sample median is the value at the middle position for an odd number of observations, or the average of the two middle observations for an even number.

The Median-of-Halves Method

In the median-of-halves method, first find the sample median. If \(n\) is odd, leave the overall median out of both halves. If \(n\) is even, split the ordered data into the lower and upper halves of equal size. Then define \(Q_1\) as the median of the lower half and \(Q_3\) as the median of the upper half. This makes the rule explicit, including what to do when the overall median is a data value.

Worked Example: Median of Halves for Six Observations

Suppose six hypothetical commute times, in minutes, are \(1, 5, 9, 12, 16, 20\). They are already in increasing order. Because \(n=6\) is even, the lower half is \(1, 5, 9\) and the upper half is \(12, 16, 20\).

The median of the lower half is \(5\), so the median-of-halves method gives \(Q_1=5\) minutes. The median of the upper half is \(16\), so it gives \(Q_3=16\) minutes. In this method each quartile is an observed commute time.

With an odd number of observations, excluding the overall median matters. For example, with five ordered values, the lower and upper halves each contain two observations after the central value is set aside. The median of either two-value half is the average of its two observations. Including the overall median in both halves is another convention sometimes encountered, but it is not the median-of-halves rule used here. A result should name its convention rather than leave this choice implicit.

Interpolation-Based Quartiles

An interpolation rule assigns a position to each desired percentile. If the assigned position lies between two observations, the quartile is calculated as a weighted average of those neighboring observations. The weights depend on how far the position lies between them.

Definition: Under the common inclusive interpolation convention, the position for proportion \(p\) is \(h=1+(n-1)p\). For quartiles, use \(p=0.25\) for \(Q_1\) and \(p=0.75\) for \(Q_3\). If \(h=j+g\), where \(j\) is the integer part of \(h\) and \(0 \leq g < 1\), calculate the value as \(x_{(j)}+g\bigl(x_{(j+1)}-x_{(j)}\bigr)\). If \(g=0\), the value is simply \(x_{(j)}\).

This rule is often called the inclusive or type 7 convention. For \(Q_1\), the position is \(1+0.25(n-1)\); for \(Q_3\), it is \(1+0.75(n-1)\). When a position is fractional, \(g\) is the fractional part. Thus, if the position is \(2.25\), the quartile is one quarter of the way from the second observation to the third.

Worked Example: Interpolating Between Two Observations

Use the same hypothetical commute times, \(1, 5, 9, 12, 16, 20\), to calculate quartiles under the inclusive interpolation convention. Here \(n=6\).

For \(Q_1\), the position is \(h=1+(6-1)(0.25)=2.25\). This is a quarter of the way between \(x_{(2)}=5\) and \(x_{(3)}=9\), so

$$ Q_1=(1-0.25)(5)+0.25(9)=3.75+2.25=6\text{ minutes}. $$

For \(Q_3\), the position is \(h=1+(6-1)(0.75)=4.75\). This is three quarters of the way between \(x_{(4)}=12\) and \(x_{(5)}=16\), so

$$ Q_3=(1-0.75)(12)+0.75(16)=3+12=15\text{ minutes}. $$

Thus, the inclusive interpolation convention gives \(Q_1=6\) minutes and \(Q_3=15\) minutes. These differ from the median-of-halves results, \(5\) and \(16\) minutes, even though the observations are unchanged.

Why the Interpolation Formula Works

Interpolation treats the value at a fractional position as lying proportionally between the two adjacent observations. If a position is \(j+g\), it is a fraction \(g\) of the distance from position \(j\) to position \(j+1\). Starting at \(x_{(j)}\), move a fraction \(g\) of the gap \(x_{(j+1)}-x_{(j)}\). This gives the following expression:

$$ x_{(j)}+g\bigl(x_{(j+1)}-x_{(j)}\bigr) =(1-g)x_{(j)}+g x_{(j+1)}. $$

The equality follows by distributing \(g\): \(x_{(j)}+g x_{(j+1)}-g x_{(j)}=(1-g)x_{(j)}+g x_{(j+1)}\). The two weights, \(1-g\) and \(g\), add to 1. If the neighboring observations are \(5\) and \(9\), and \(g=0.25\), the result is \(0.75(5)+0.25(9)=6\): the value is one quarter of the way from 5 to 9, not one quarter of the way from 9 to 5.

Different Interpolation Rules

The inclusive convention is not the only interpolation rule. Another common rule assigns position \(h=(n+1)p\), then interpolates between adjacent observations when this position is fractional. This is often called the exclusive or type 6 convention. It can produce different positions from the inclusive rule because \(1+(n-1)p\) and \((n+1)p\) are generally not equal. For example, with \(n=6\) and \(p=0.25\), they give positions \(2.25\) and \(1.75\), respectively.

Worked Example: Comparing Two Interpolation Positions

For the hypothetical commute times \(1, 5, 9, 12, 16, 20\), calculate \(Q_1\) using the convention with position \(h=(n+1)p\). With \(n=6\), the position is \(h=(6+1)(0.25)=1.75\). This lies three quarters of the way from \(x_{(1)}=1\) to \(x_{(2)}=5\).

The calculation is

$$ Q_1=(1-0.75)(1)+0.75(5)=0.25+3.75=4\text{ minutes}. $$

The same six observations gave \(Q_1=6\) minutes under the inclusive interpolation convention and \(Q_1=5\) minutes under the median-of-halves method. Under this second interpolation convention, it is \(4\) minutes. These are not arithmetic contradictions: they are the outputs of different definitions.

The rule \(h=(n+1)p\) is straightforward for the quartile positions in this example. For some data sizes and percentiles, it can put the position outside the observed range; software must then follow its own specified endpoint rule. This is another reason to check a program’s documentation rather than assume that every tool uses the same percentile calculation.

Odd-Sized Data Sets Make the Differences Visible

Even when the middle observation is excluded consistently, the median-of-halves method and an interpolation rule need not agree for odd \(n\). The following example shows that the difference can occur even when quartile positions under the inclusive rule are integers.

Worked Example: Five Ordered Values

Consider five hypothetical test scores, \(2, 4, 7, 10, 13\), in points. The overall median is \(7\). For the median-of-halves method, exclude that value: the lower half is \(2, 4\), and the upper half is \(10, 13\). Therefore,

$$ Q_1=\frac{2+4}{2}=3\text{ points},\qquad Q_3=\frac{10+13}{2}=11.5\text{ points}. $$

Under the inclusive interpolation convention, the quartile positions are \(1+(5-1)(0.25)=2\) and \(1+(5-1)(0.75)=4\). These are exact positions, so \(Q_1=x_{(2)}=4\) points and \(Q_3=x_{(4)}=10\) points. The methods differ because one takes the median of each half and the other selects observations at its defined percentile positions.

Why Software May Report Different Quartiles

Statistical software has to turn a percentile request into a numerical algorithm. Some functions use the inclusive position rule, some use the exclusive position rule, and others use a different convention or provide several options. Even two functions in the same software package may have distinct defaults or names for their methods. Consequently, entering the same data into two programs does not guarantee identical quartiles.

When quartile values matter, record enough detail for someone else to reproduce them:

  • Confirm that the same observations were used and sorted in the same way.
  • Identify whether quartiles were calculated by the median-of-halves method or an interpolation rule.
  • For interpolation, record the position rule or the software function and its method setting.
  • Keep the data’s units and any rounding consistent when reporting results.

A difference between two reported quartiles is not automatically evidence that one calculation is wrong. It may arise from different conventions. However, a calculation can still contain an arithmetic or sorting error, so check both the rule and the work rather than treating every disagreement as harmless.

Common Mistake: Treating One Convention as Universal

A common mistake is to see a quartile reported by software and assume that it must match the median of the lower or upper half. That reasoning silently treats one definition as universal. The correction is to identify the convention first, then use that method consistently. If a comparison requires values calculated by the same method, do not mix a hand-calculated median-of-halves \(Q_1\) with a software-interpolated \(Q_3\).

Another frequent error is to interpolate in the wrong direction or calculate a weighted average incorrectly. For a position 25% of the way from 5 to 9, the calculation is \(0.75(5)+0.25(9)=6\), not \(0.75(5)+0.25\), and not a value closer to 9 than the position warrants. The weights apply to the observations and must add to 1.

Key takeaway: Quartiles depend on a stated convention. The median-of-halves method and interpolation methods can give different, internally correct results for the same ordered data. Sort first, identify the rule, calculate carefully, and report the method when reproducibility matters.

Check Your Understanding

Try these questions without looking back.

  1. For \(3, 6, 8, 11, 15, 19\), find \(Q_1\) and \(Q_3\) by the median-of-halves method.
  2. For the same six values, use the inclusive position rule \(h=1+(n-1)p\) to calculate \(Q_1\). Show the position and interpolation.
  3. For five ordered values, how does the median-of-halves rule described here treat the overall median when forming the lower and upper halves?
  4. Explain why two software packages can report different quartiles for identical observations without either result necessarily being an arithmetic mistake.
  5. If a quartile position is 2.4, which two observations are used for interpolation, and what fraction of the gap between them is used?