IQR Calculator

IQR Calculator

Calculate quartiles, interquartile range, outlier fences, and a box plot from any data set.

IQR calculatorRuns entirely in your browser
Separate values with commas, spaces or line breaks. Paste a column straight from a spreadsheet.
Try:
ResultExclusive method · n = 8
Interquartile range7.5IQR = 11 − 3.5
Q1
3.5
Median
7.5
Q3
11

Box plot

Box and whisker plot of your dataBox plot. Minimum 2, lower whisker 2, Q1 3.5, median 7.5, Q3 11, upper whisker 18, maximum 18. No outliers.Interquartile range: Q1 3.5 to Q3 11, IQR 7.5Median: 7.5Q1 3.5Med 7.5Q3 1151015
Middle 50% (Q1 to Q3)MedianRange within the fences
Quartile methodExclusiveAdvanced settings
Quartile method

Quartiles have no single agreed definition. Why these differ.

Fence multiplier

Data summary

Count
8
Minimum
2
Maximum
18
Range
16
Mean
8

Outlier fences (1.5 × IQR)

Lower fence
-7.75
Upper fence
22.25
Outliers
None

How we calculated it

Your data, as entered
8, 3, 12, 4, 7, 2, 18, 10
8 values.
Sorted from smallest to largest
23478101218
An even count, so the split falls cleanly between the two middle values.
Median (Q2)
No single middle value, so average the two in the middle:(7 + 8) ÷ 2 = 7.5
Split into halves
Lower half  →  2, 3, 4, 7Upper half  →  8, 10, 12, 18
Q1 and Q3 are the medians of those halves
Q1 = (3 + 4) ÷ 2 = 3.5Q3 = (10 + 12) ÷ 2 = 11
Interquartile range
IQR = Q3 − Q1IQR = 11 − 3.5 = 7.5
Outlier fences (1.5 × IQR)
Lower = Q1 − 1.5 × IQR = 3.5 − 1.5 × 7.5 = -7.75Upper = Q3 + 1.5 × IQR = 11 + 1.5 × 7.5 = 22.25
Every value falls inside the fences, so nothing is flagged.
Compare all four quartile methods
MethodQ1MedianQ3IQR
Exclusive3.57.5117.5
Inclusive3.57.5117.5
Interpolation, rank p(n+1)3.257.511.58.25
Interpolation, rank (n−1)p+13.757.510.56.75

These methods give 3 different answers for this data set. The highlighted row is the method currently selected above.

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.

25% 25% 25% 25% Q1 median Q3 min max IQR — the middle 50%
Q1, the median and Q3 cut sorted data into four equal-sized groups. The IQR is the distance from Q1 to Q3.

The formula

IQR = Q3 − Q1 Q1 — the first quartile, the value a quarter of the way through the sorted data
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

  1. Sort the values from smallest to largest. Keep duplicates; they count.
  2. Find the median. With an odd count it is the middle value. With an even count, average the two middle values.
  3. 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.
  4. Q1 is the median of the lower half. Q3 is the median of the upper half.
  5. 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:

MethodQ1Q3IQRUsed by
Exclusive264TI-83/84, most US textbooks
Inclusive (Tukey's hinges)2.55.53R fivenum()
Interpolation, rank p(n+1)264Excel QUARTILE.EXC, NIST
Interpolation, rank (n−1)p+12.55.53Excel 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.

Practical advice

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:

lower fence = Q1 − 1.5 × IQR upper fence = Q3 + 1.5 × IQR Values outside either fence are flagged. Using 3 × IQR instead of 1.5 flags only extreme outliers.

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

Data: 8, 3, 12, 4, 7, 2, 18, 10

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

Data: 12, 15, 14, 18, 16, 13, 17, 92

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

Data: 1, 2, 3, 4, 5, 6, 7

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