IQRCalculator

IQR Calculator

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

Separate values with commas, spaces or new lines. You can paste a column from a spreadsheet.

Options
Quartile method
Fence multiplier

Result

Interquartile range7.5IQR = 11 − 3.5
Q1
3.5
Median
7.5
Q3
11

Box plot

Box-and-whisker plot of your dataQ1 3.5Med 7.5Q3 1151015

Middle 50% (Q1 to Q3)MedianWhiskers: furthest values inside the fencesOutliers

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 it was calculated
  1. Sort from smallest to largest
    23478101218

    8 values.

  2. Find the median (Q2)
    Even count: average the two middle values, (7 + 8) ÷ 2 = 7.5.
  3. Split the data into halves
    Lower half: 2, 3, 4, 7
    Upper half: 8, 10, 12, 18

    An even count splits cleanly between the two middle values.

  4. Q1 and Q3 are the medians of the halves
    Q1 = 3.5  ·  Q3 = 11
  5. Interquartile range
    IQR = Q3 − Q1 = 11 − 3.5 = 7.5
  6. Outlier fences (1.5 × IQR)
    Lower fence = Q1 − 1.5 × IQR = 3.5 − 1.5 × 7.5 = −7.75
    Upper fence = Q3 + 1.5 × IQR = 11 + 1.5 × 7.5 = 22.25

    Every value falls inside the fences, so nothing is flagged.

Compare methods
MethodQ1MedianQ3IQR
Exclusive (median excluded)3.57.5117.5
Inclusive (Tukey’s hinges)3.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 selected.

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.

Q1, the median and Q3 cut sorted data into four groups of equal size, a quarter of the values in each. The IQR spans the two middle groups: it is the distance from Q1 to Q3.

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%Q1medianQ3minmaxIQR — 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 − Q1Q1 — 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 the section on why two calculators can 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 (this calculator’s default) 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. The two interpolation methods skip the halves and locate Q1 and Q3 by rank instead; the working shows the rank and the interpolation.

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
Exclusive (median excluded)264TI-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 (median excluded) because that is the rule taught in most secondary and introductory courses, and the number a TI-84 returns — but its Compare methods table shows 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, but the two interpolation rules can still differ, so the method matters whatever the count.

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 × IQRValues outside either fence are flagged. Choosing 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 sample standard deviation is about 27.3. The IQR is 4 — the same value it would have if the 92 were 25, or 2,500. 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 is the halves rule taught in most textbooks, so on many data sets neither matches it. Select the matching method in the calculator and the numbers will line up.

How many values do I need?

The calculator accepts two or more, but four is the practical minimum — below that each quarter contains less than one value and the quartiles stop meaning much. The arithmetic still works at n = 2 or 3, and the result carries a note saying it tells you little 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