What the interquartile range measures
The interquartile range (IQR) is a measure of statistical dispersion: it tells you how spread out the middle half of your data is. Formally, IQR = Q3 − Q1, where Q1 is the first quartile (the 25th percentile) and Q3 is the third quartile (the 75th percentile). Between those two cut points sit exactly the middle 50% of the observations, so the IQR is the width of that central block. In a box-and-whisker plot, the IQR is literally the length of the box.
Its defining virtue is robustness. Unlike the range (max − min) or the standard deviation, the IQR discards the bottom 25% and top 25% of the data, so a single wild value cannot inflate it. That is why the IQR is the preferred spread measure for skewed data such as incomes, house prices, or reaction times, where a few extreme observations would distort mean-based statistics.
How the quartiles are calculated
This calculator uses the linear-interpolation method, the same one Excel's QUARTILE.INC function and NumPy's default percentile use. The steps are:
- Sort the data from smallest to largest.
- For a percentile p (0.25 for Q1, 0.75 for Q3), compute the fractional position
pos = p × (n − 1), where n is the number of values and positions are 0-indexed. - If
poslands between two data points, interpolate:value = data[floor(pos)] + frac × (data[floor(pos)+1] − data[floor(pos)]).
Worked example. For the sorted set 7, 15, 36, 39, 40, 41, 42, 43, 47, 49 (n = 10): Q1 position = 0.25 × 9 = 2.25, giving 36 + 0.25 × (39 − 36) = 36.75. Q3 position = 0.75 × 9 = 6.75, giving 42 + 0.75 × (43 − 42) = 42.75. So IQR = 42.75 − 36.75 = 6, and the median is the average of the 5th and 6th values, (40 + 41)/2 = 40.5.
Note that different software sometimes reports slightly different quartiles because there are several accepted definitions (Tukey's hinges, the "exclusive" method used by Excel's QUARTILE.EXC, and others). They agree for large datasets and differ only in how they handle the endpoints of small samples.
Using the IQR to detect outliers
The most common outlier rule, introduced by John Tukey, uses "fences" built from the IQR:
- Lower fence: Q1 − 1.5 × IQR
- Upper fence: Q3 + 1.5 × IQR
Any value below the lower fence or above the upper fence is flagged as a (mild) outlier and drawn as an individual point beyond the whiskers of a box plot. Points beyond Q1 − 3×IQR or Q3 + 3×IQR are sometimes called extreme outliers. For the example above, the fences are 36.75 − 9 = 27.75 and 42.75 + 9 = 51.75, so the value 7 (and 15) fall below the lower fence and are flagged.