MathsStatistics & Probability

Quartile
calculator.

Find Q1, Q3 and the interquartile range, using the rule your class or software uses.

How it's worked out

Quartiles cut a sorted list into four parts that hold about the same number of values. Q1 has about a quarter of the values below it, Q2 is the median, and Q3 has about three quarters below it. The interquartile range, or IQR, is the width of the middle half.

IQR\displaystyle \text{IQR}=Q3−Q1\displaystyle {}= Q_3 - Q_1

Every method finds the median the same way, but no single rule for Q1 and Q3 ever won out. This tool offers the four you are most likely to meet.

  • Median of halves, median left out. Split the sorted list at the median and take the median of each half. With an odd count, the median stays out of both halves. The Math Doctors tie this rule to the TI-83 and the Moore and McCabe textbook.
  • Median of halves, median kept in. The same split, but with an odd count the median goes in both halves. This is Tukey's version.
  • Position counted from the ends. This is type 7 in R's list of quantile rules and R's default. QUARTILE.INC in Excel gives the same answer on Microsoft's example.
  • Position out of n + 1. This is type 6, which R says Minitab and SPSS use. QUARTILE.EXC in Excel gives the same answer on Microsoft's example.

The last two find a position in the sorted list, where pp is 0.25 for Q1 and 0.75 for Q3. When the position falls between two values, you go that fraction of the way from one to the next. A position of 3.5 means halfway from the third value to the fourth.

type 7 position\displaystyle \text{type 7 position}=(n−1)p+1\displaystyle {}= (n - 1)p + 1
type 6 position\displaystyle \text{type 6 position}=(n+1)p\displaystyle {}= (n + 1)p

The fences from NIST sit beyond the quartiles. A value past an inner fence is a mild outlier, and a value past an outer fence is an extreme one.

inner fences\displaystyle \text{inner fences}=Q1−1.5×IQR,;Q3+1.5×IQR\displaystyle {}= Q_1 - 1.5 \times \text{IQR},; Q_3 + 1.5 \times \text{IQR}
outer fences\displaystyle \text{outer fences}=Q1−3×IQR,;Q3+3×IQR\displaystyle {}= Q_1 - 3 \times \text{IQR},; Q_3 + 3 \times \text{IQR}

Three more figures come from the same numbers. The quartile deviation is half the IQR. Bowley skewness compares the two sides of the median and always lies between −1 and 1. The coefficient of dispersion sets the spread against the size of the values, so you can compare sets on different scales.

Bowley skewness\displaystyle \text{Bowley skewness}=Q3+Q1−2Q2Q3−Q1\displaystyle {}= \frac{Q_3 + Q_1 - 2Q_2}{Q_3 - Q_1}
coefficient of dispersion\displaystyle \text{coefficient of dispersion}=Q3−Q1Q3+Q1\displaystyle {}= \frac{Q_3 - Q_1}{Q_3 + Q_1}

Worked examples

Priya checks Excel against her calculator

Priya has 11 values: 6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49. The median is the sixth, 40. Leaving it out, the lower half has a median of 15 and the upper half a median of 43, so her IQR is 28.

Microsoft uses the same 11 values to show QUARTILE.EXC, which gives 15 and 43, matching her halves. QUARTILE.INC is different: it lands on 25.5 and 42.5, an IQR of 17. Nobody made an error, and the median is 40 under every rule. The two methods simply answer with different quartiles.

Open this example in the tool

Sam finds an even count easier by hand

Sam has 1, 2, 4, 7, 8, 9, 10, 12. The median is halfway between 7 and 8, so 7.5. The halves are 1, 2, 4, 7 and 8, 9, 10, 12, with medians of 3 and 9.5. With an even count, the median is in neither half, so the two halves methods agree: both give an IQR of 6.5.

His spreadsheet says 3.5 for Q1 instead. QUARTILE.INC finds position 2.75, which is three quarters of the way from 2 to 4, and Microsoft's own example shows that same 3.5. Q3 sits at 9.25, so the IQR comes to 5.75. Sam should report the rule his teacher expects.

Open this example in the tool

One salary out of thirteen is far above the rest

Thirteen salaries in thousands of dollars run from 38 to 61, plus one of 240. The mean is 63.2 and the standard deviation is 53.6, both pulled up by one person. The quartiles barely notice: Q1 is 43, the median is 48, Q3 is 56.5, and the IQR is 13.5.

The upper outer fence is 97, so 240 is an extreme outlier. Take it out and the standard deviation falls to 7.1, while the IQR moves only from 13.5 to 10.5. That is why the IQR suits pay, house prices and other figures with a long tail.

Open this example in the tool

Reading your result

Say which method you used. On Priya's 11 values the IQR is 28 or 17, depending on the rule. With 1,001 evenly spaced values, the four methods give an IQR from 500 to 501, so the choice matters most in small sets.

Read the median against the quartiles. If the median sits closer to Q1, the upper part of the middle half is longer and Bowley skewness is positive. A value near 0 means the two sides match, whatever the tails are doing, because this measure never looks past the quartiles.

Treat the fences as a screen. A flagged value deserves a second look, not automatic deletion. Even on perfectly normal data, about 0.7% of values fall beyond the inner fences, which comes to roughly 7 in every 1,000. In a list of 10,000 readings, you should expect to see some.

To draw the same figures as a chart, use the box plot calculator. For another cut point, such as the 90th percentile, use the percentile calculator.

Common mistakes

  • Mixing methods. A Q1 from a calculator and a Q3 from a spreadsheet do not belong in one IQR. Use one rule for both, and for every group you compare.
  • Forgetting to sort. By hand, the median and the halves only mean something once the list is in order. An unsorted list gives a confident wrong answer.
  • Reading an IQR of 0 as no spread. With 5, 5, 5, 5, 5, 5, 5, 5, 6, 9, Q1 and Q3 are both 5, the IQR is 0, and the fences sit on top of it. Every value that is not 5 gets flagged, which says more about the repeated values than about outliers.
  • Trusting quartiles from very few values. With the values 1 to 7, the type 6 rule gives Q1 = 2 and Q3 = 6, each a single value from the list. Add or drop one value and the answer can jump, so report the method and the count.

Questions people ask

They follow different rules. A TI calculator splits the list at the median and takes the median of each half, while QUARTILE.INC finds a position and interpolates. On the 11 values above, the first gives a Q1 of 15 and the second gives 25.5. QUARTILE.EXC happens to match the TI on these values, but not on the 8 values in Sam's example.

Sources