Interquartile Range Calculator

IQR
Next

Paste a list of numbers and the calculator returns the first quartile (Q1), third quartile (Q3), the interquartile range (IQR = Q3 - Q1), and the Tukey fences that flag statistical outliers (Q1 - 1.5 * IQR and Q3 + 1.5 * IQR). Useful for boxplot data prep, A/B test cleaning and any analysis where outliers would skew the mean.

How to calculate the IQR

  1. 1

    Paste your data

    Comma, space or newline-separated numbers: the parser accepts all common formats.

  2. 2

    Pick the quartile method

    Exclusive (Tukey), inclusive (percentile), or Moore & McCabe. Results can differ by a few tenths for small samples.

  3. 3

    Read the summary

    Min, Q1, median, Q3, max plus IQR, lower and upper outlier fences and a list of flagged outliers.

  4. 4

    Copy the result

    Copy the five-number summary in a format ready for a report, a boxplot or a paste into R/Python.

Quartile calculation methods

Different software packages use different quartile definitions. The differences are small for large samples and can be meaningful for n < 20.

Method Used by Formula idea
Tukey (exclusive) R default, boxplots Exclude median from halves when odd n
Inclusive (Moore & McCabe) Many textbooks, Excel Include median in both halves
Percentile (type 7) NumPy default, pandas Linear interpolation on rank
Method 5 / Weibull Some stats textbooks (i - 0.5) / n plotting positions

The tool defaults to Tukey because it matches R’s quantile(type = 5) and the classic Tukey boxplot.

The IQR in three uses

  • Spread: IQR is a robust measure of scatter; unlike standard deviation, it is not pulled by a single extreme value.
  • Outliers: A value below Q1 - 1.5 * IQR or above Q3 + 1.5 * IQR is an outlier by the Tukey rule. Extreme outliers use 3 * IQR.
  • Boxplots: The box spans Q1 to Q3, the line inside is the median, the whiskers extend to the last value inside the 1.5 * IQR fences.

Worked example

Dataset: 2, 4, 5, 7, 8, 10, 12, 15, 50

  • Sorted: same as input (already sorted).
  • Median: 8 (middle value).
  • Lower half (exclusive): 2, 4, 5, 7; Q1 = 4.5.
  • Upper half (exclusive): 10, 12, 15, 50; Q3 = 13.5.
  • IQR: 13.5 - 4.5 = 9.
  • Lower fence: 4.5 - 1.5 * 9 = -9 (no lower outliers).
  • Upper fence: 13.5 + 1.5 * 9 = 27 (50 is flagged as an outlier).

Common mistakes

  • Confusing IQR with range. Range is max - min and is very sensitive to outliers; IQR is the middle 50% and is robust.
  • Mixing up methods silently. If you compute Q1 in Excel and Q3 in R, you might end up with a mismatched pair and a wrong IQR.
  • Applying the 1.5 * IQR rule automatically. It is a rule of thumb, not a statistical test. For heavy-tailed distributions (financial returns) the fences are too tight.

Frequently Asked Questions

The IQR is Q3 - Q1, the range covering the middle 50% of a sorted dataset. It is a robust measure of spread that is not influenced by extreme values the way the full range is.

There are at least nine published quartile methods. The differences are negligible for large samples and can disagree by a fraction of a unit for small samples. R, Excel and NumPy each use different defaults.

Tukey’s rule flags any value below Q1 - 1.5 * IQR or above Q3 + 1.5 * IQR as a suspected outlier. It is a heuristic designed for roughly normal data, use it as a starting point, not a proof of error.

Yes. The calculator sorts values and computes quartiles on any real-valued dataset, negative or mixed. It does not impose a lower bound.

Related Tools

Tool available in other languages