What the interquartile range measures
The interquartile range is the distance between the 25th percentile and the 75th percentile of a data set — the width of the middle half. Sort your values, cut away the bottom quarter and the top quarter, and the IQR is what is left over.
That makes it a resistant measure of spread. Replace the largest value in a set with a number a thousand times bigger and the range explodes, the standard deviation balloons, and the IQR usually does not move at all. Nothing in the calculation depends on how far out the extremes sit, only on where the quarter-points fall.
The formula
Q3 — the third quartile, the value three quarters of the way through
The subtraction is the easy part. Everything interesting happens in how Q1 and Q3 are located, which is where different software gives different answers — see why methods disagree below.
Calculating it by hand
- Sort the values from smallest to largest. Keep duplicates; they count.
- Find the median. With an odd count it is the middle value. With an even count, average the two middle values.
- Split the data in two at the median. Under the exclusive rule the median itself joins neither half; under the inclusive rule it joins both.
- Q1 is the median of the lower half. Q3 is the median of the upper half.
- Subtract: IQR = Q3 − Q1.
The calculator above shows every one of these steps against your own numbers, and rewrites them when you change the method.
Why two calculators can give different answers
There is no single agreed definition of a quartile. Statistics software has settled on at least four conventions, and they disagree with each other on ordinary data sets. This is not a rounding difference — the answers are genuinely different numbers.
On the seven values 1, 2, 3, 4, 5, 6, 7:
| Method | Q1 | Q3 | IQR | Used by |
|---|---|---|---|---|
| Exclusive | 2 | 6 | 4 | TI-83/84, most US textbooks |
| Inclusive (Tukey's hinges) | 2.5 | 5.5 | 3 | R fivenum() |
| Interpolation, rank p(n+1) | 2 | 6 | 4 | Excel QUARTILE.EXC, NIST |
| Interpolation, rank (n−1)p+1 | 2.5 | 5.5 | 3 | Excel QUARTILE.INC, NumPy, pandas |
A 33% difference in the answer, from the same seven numbers. This calculator defaults to exclusive because that is the rule taught in most secondary and introductory courses, and the number a TI-84 returns — but it will show you all four at once, and the quartile calculator goes through each rule in detail.
If you are checking homework, match your instructor's or your calculator's method. If you are reporting a result, say which method you used. For even-sized data sets the exclusive and inclusive rules always agree, so the question only arises when your count is odd.
IQR and outliers
The IQR is the basis of the most widely used outlier rule. Build a fence a set multiple of the IQR beyond each quartile, then flag anything outside it:
The rule works because the IQR itself is unaffected by the very values it is being used to detect. A mean-and-standard-deviation rule has the opposite problem: a large outlier inflates the standard deviation, widening the threshold that was supposed to catch it.
A flagged value is not automatically an error. The 1.5 multiplier is a convention, not a test of truth. Genuinely skewed data — incomes, response times, file sizes — produces flagged values routinely without anything being wrong. Investigate before you delete. The outlier calculator shows how far past the fence each flagged value sits, which is usually more informative than the flag itself.
When to use the IQR instead of the standard deviation
Reach for the IQR when the data is skewed, when it contains values you do not want to let dominate the summary, or when you are already quoting a median. Median and IQR belong together; mean and standard deviation belong together. Mixing them — a median with a standard deviation — reads as a mistake to anyone who notices.
Reach for the standard deviation when the data is roughly symmetric, when you need a measure that uses every observation, or when the next step in your analysis expects one — most inferential statistics are built on it.
Worked examples
Eight values, nothing unusual
Sorted: 2, 3, 4, 7, 8, 10, 12, 18. Eight values, so the count is even and the two halves split cleanly.
- Median = (7 + 8) ÷ 2 = 7.5
- Lower half is 2, 3, 4, 7 → Q1 = (3 + 4) ÷ 2 = 3.5
- Upper half is 8, 10, 12, 18 → Q3 = (10 + 12) ÷ 2 = 11
- IQR = 11 − 3.5 = 7.5
Fences: 3.5 − 1.5 × 7.5 = −7.75 and 11 + 1.5 × 7.5 = 22.25. Every value falls inside, so nothing is flagged. Because the count is even, the inclusive method gives exactly the same answer.
One value far from the rest
Sorted: 12, 13, 14, 15, 16, 17, 18, 92.
- Q1 = (13 + 14) ÷ 2 = 13.5, Q3 = (17 + 18) ÷ 2 = 17.5, IQR = 4
- Upper fence = 17.5 + 1.5 × 4 = 23.5, so 92 is flagged.
Note what the 92 did to each measure. The range is 80. The standard deviation is about 26.6. The IQR is 4 — the same value it would have if the 92 were 25, or 2500. That resistance is the whole point.
An odd count, where the method starts to matter
Seven values, so there is a single middle value: the median is 4.
- Exclusive — the 4 is set aside. Lower half 1, 2, 3 → Q1 = 2. Upper half 5, 6, 7 → Q3 = 6. IQR = 4.
- Inclusive — the 4 joins both halves. Lower half 1, 2, 3, 4 → Q1 = 2.5. Upper half 4, 5, 6, 7 → Q3 = 5.5. IQR = 3.
Same data, two defensible answers. Switch the method in the panel above and watch the working rewrite itself.
Questions
Can the interquartile range be negative?
No. Q3 is never smaller than Q1 under any of the four methods, so the IQR is always zero or positive. An IQR of exactly 0 means at least half your values are identical — the middle half has collapsed to a single number.
What is a "good" IQR?
There is no such thing in the abstract; it carries the units of your data. An IQR of 4 is large for shoe sizes and tiny for house prices. To compare spread across different units, use the coefficient of variation instead.
Why does Excel give me a different IQR?
Because Excel has two quartile functions that disagree with each other. QUARTILE.INC uses the rank (n−1)p+1 and QUARTILE.EXC uses p(n+1), and neither matches the halves rule taught in most textbooks. Select the matching method in the panel above and the numbers will line up.
How many values do I need?
Four is the practical minimum for this calculator — below that each quarter contains less than one value and the quartiles stop meaning much. The arithmetic still works at n = 2 or 3, but it will not tell you anything useful about spread.
Is the IQR the same as the middle 50% of values?
It is the width of that middle 50%, not the values themselves. The values from Q1 to Q3 are the middle half; the single number Q3 − Q1 is how far apart the ends of that half sit.
Method & sources
- Quartile and outlier definitions, including the p(N+1) rank rule with linear interpolation — NIST/SEMATECH e-Handbook of Statistical Methods
- Comparison of the halves and interpolation conventions — Wikipedia: Quartile — survey of computation methods