Range, Quartiles and IQR Calculator

Paste or type your numbers and pick a quartile rule. Values outside the 1.5 × IQR fences are listed as outliers.

Tukey's hinges are the box-plot definition. Interpolation matches Excel, Google Sheets, R's default and NumPy.
Separate numbers with commas, spaces or new lines.

Range

29

Minimum

1

First quartile (Q1)

3.5

Median (Q2)

6.5

Third quartile (Q3)

9.5

Maximum

30

Interquartile range (IQR)

6

Lower fence (Q1 − 1.5 × IQR)

-5.5

Upper fence (Q3 + 1.5 × IQR)

18.5

Outliers

1

Outlying values

30

Count

12

Sorted values

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 30

How it works

The range is the simplest measure of spread, the distance from the smallest value to the largest, but one stray value can make it huge. The interquartile range (IQR) looks only at the middle half of the data: the first quartile Q1 has a quarter of the values below it, the third quartile Q3 has three quarters below it, and the IQR is the distance between them. Together with the minimum, median and maximum they make the five-number summary that a box plot draws.

Quartiles are not uniquely defined for a small list, and different software gives slightly different answers. Tukey's hinges split the sorted list at the median and take the median of each half (with an odd count the median goes in both halves); this is the rule box plots were invented with. The interpolation rule finds the position 0.25 × (n − 1) in the sorted list and interpolates between the two neighbouring values; it is what Excel's QUARTILE.INC, Google Sheets, R and NumPy return by default.

Tukey's fences flag outliers: any value more than 1.5 IQRs below Q1 or above Q3 sits outside the box plot's whiskers and is listed here. It is a screening rule that depends only on the middle half of the data, so a few extreme values cannot hide themselves by stretching the spread.

Formula

range = max − min
Tukey hinges:  Q1 = median of the lower half,  Q3 = median of the upper half
               (an odd count puts the median in both halves)
Interpolation: h = p × (n − 1),  Q = s[⌊h⌋] + (h − ⌊h⌋) × (s[⌊h⌋ + 1] − s[⌊h⌋])
               with p = 0.25 for Q1 and 0.75 for Q3, s sorted and indexed from 0
IQR = Q3 − Q1
lower fence = Q1 − 1.5 × IQR      upper fence = Q3 + 1.5 × IQR

Example

Twelve values: 7, 12, 3, 9, 1, 30, 5, 8, 2, 10, 6, 4. Sorted: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 30. The minimum is 1, the maximum 30, so the range is 29, and the median is (6 + 7) ÷ 2 = 6.5.

By Tukey's hinges the lower half is 1, 2, 3, 4, 5, 6 with median 3.5, and the upper half is 7, 8, 9, 10, 12, 30 with median 9.5, so the IQR is 6. The fences are 3.5 − 9 = −5.5 and 9.5 + 9 = 18.5; the value 30 is above the upper fence and is the one outlier. By the interpolation rule Q1 is at position 2.75, between 3 and 4, giving 3.75, and Q3 is at position 8.25, giving 9.25; the IQR is 5.5, the fences −4.5 and 17.5, and 30 is still the only outlier.

Assumptions and limitations

  • Different software uses different quartile rules and gets different Q1 and Q3 for the same data. The two offered here are the box-plot definition (Tukey hinges) and the Excel / R default (linear interpolation). Say which you used when reporting.
  • The 1.5 × IQR fences are a screening rule, not a test: a value outside them is unusual relative to the middle half of the data, not proven to be an error.
  • Every entry must be a number. Text such as units in the list stops the calculation and names the offending entry.

Frequently asked questions

Why does Excel give a different Q1 from my textbook?

Because they use different rules. Many textbooks use Tukey's median-of-halves hinges; Excel's QUARTILE.INC interpolates at position 0.25 × (n − 1). Both are legitimate and they agree when n − 1 is a multiple of 4. Switch the quartile method here to see each one.

Should I delete the outliers?

Not automatically. The fences say a value is far from the middle half of the data, not that it is wrong. Check whether it is a recording error, a different population, or a genuine extreme; a genuine extreme belongs in the data, and a robust summary such as the median and IQR already limits its influence.