Skip to main content
v2026.11,858 entries · CC-BY 4.0

How to Find an Outlier in Statistics: The IQR Rule, Step by Step

Find outliers with the 1.5 x IQR fence rule: step-by-step arithmetic, mild vs extreme outliers, Excel, R and Python code, and how to report them.

Written and maintained by CASRAI Editorial Board

Last updated

To find an outlier in statistics, sort the data, calculate the first and third quartiles (Q1 and Q3), compute the interquartile range (IQR = Q3 − Q1), and flag any value below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR. That is the fence rule used for box plots in the NIST/SEMATECH e-Handbook of Statistical Methods, and it works on any data set without assuming a distribution. The rest of this page shows the arithmetic on a real data set, the one trap that changes the answer (which quartile definition you use), and what to do once a value is flagged.

What is an outlier?

The NIST/SEMATECH e-Handbook defines an outlier as “an observation that lies an abnormal distance from other values in a random sample from a population.” The definition is deliberately loose: whether a point is “abnormal” depends on a rule you choose. NIST also notes that outliers should be investigated carefully, because they often contain valuable information about the process or about how the data were gathered and recorded.

How to find an outlier: the 1.5 × IQR rule

The fence method has two tiers. NIST (e-Handbook section 7.1.6) defines the interquartile range as IQ = Q3 − Q1 and builds four fences from it:

Fence Formula A point beyond it is
Lower inner fence Q1 − 1.5 × IQ a mild outlier
Upper inner fence Q3 + 1.5 × IQ a mild outlier
Lower outer fence Q1 − 3 × IQ an extreme outlier
Upper outer fence Q3 + 3 × IQ an extreme outlier

Symbols: Q1 is the 25th percentile, Q3 is the 75th percentile, and IQ (usually written IQR) is the spread of the middle half of the data. Because quartiles ignore the extreme tails, a single wild value cannot move the fences much. The same inner fences set the whiskers of a box plot (NIST e-Handbook section 1.3.3.7); see our guides to box plots in R and SPSS for drawing them.

How to calculate an outlier: worked example

Take 15 measurements, already sorted: 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 21, 23, 26, 34, 60.

  1. Median. The 8th of 15 values is 18.
  2. Q1 (inclusive method). Position = 1 + 0.25 × (15 − 1) = 4.5, halfway between the 4th and 5th values (15 and 15), so Q1 = 15.
  3. Q3 (inclusive method). Position = 1 + 0.75 × 14 = 11.5, halfway between the 11th and 12th values (21 and 23), so Q3 = 22.
  4. IQR. 22 − 15 = 7.
  5. Inner fences. Lower = 15 − 1.5 × 7 = 4.5. Upper = 22 + 1.5 × 7 = 32.5.
  6. Outer fences. Lower = 15 − 3 × 7 = −6. Upper = 22 + 3 × 7 = 43.
  7. Compare. No value is below 4.5. 34 is above 32.5 but below 43, so it is a mild outlier. 60 is above 43, so it is an extreme outlier. The other 13 values are inside the fences.

For comparison, the mean of this data set is 21.53 and the sample standard deviation is 12.06; the single value 60 pulls both upward, which is why quartile-based fences are preferred over mean-based screens when you suspect outliers are present.

Which quartile method? The same data can give a different answer

Software does not agree on how to compute Q1 and Q3, and for small samples the difference can decide whether a point is flagged. Repeat the example with the exclusive method (position = 0.25 × (n + 1) = 4 and 0.75 × 16 = 12):

Method Q1 Q3 IQR Upper inner fence Flagged
Inclusive (Excel QUARTILE.INC, R type 7, NumPy default) 15 22 7 32.5 34 and 60
Exclusive (Excel QUARTILE.EXC, R type 6) 15 23 8 35 60 only

Under the exclusive method the upper inner fence is 23 + 1.5 × 8 = 35, so 34 sits inside it and is no longer flagged. Neither answer is wrong; they follow different quartile definitions. State which one you used. The R boxplot() function uses yet another definition (hinges), so a box plot and a hand calculation can disagree on borderline points; our box plots in R guide shows a concrete case.

How to find outliers in a data set in Excel, R or Python

Excel

With the data in A2:A16, put Q1 in D1 and Q3 in D2, then compute fences and flag each row:

D1: =QUARTILE.INC($A$2:$A$16,1)
D2: =QUARTILE.INC($A$2:$A$16,3)
D3: =D2-D1                      (IQR)
D4: =D1-1.5*D3                  (lower inner fence)
D5: =D2+1.5*D3                  (upper inner fence)
B2: =OR(A2<$D$4,A2>$D$5)       (TRUE = outlier; fill down)

R

x <- c(12,13,14,15,15,16,17,18,19,20,21,23,26,34,60)
q <- quantile(x, c(.25, .75), type = 7)
iqr <- q[2] - q[1]
x[x < q[1] - 1.5*iqr | x > q[2] + 1.5*iqr]   # 34 60

Python

import numpy as np
x = np.array([12,13,14,15,15,16,17,18,19,20,21,23,26,34,60])
q1, q3 = np.quantile(x, [0.25, 0.75])
iqr = q3 - q1
print(x[(x < q1 - 1.5*iqr) | (x > q3 + 1.5*iqr)])   # [34 60]

How to find the outlier of a data set: reading the result

Where the value falls NIST label Reasonable next step
Inside both inner fences Not flagged No action from this rule
Beyond an inner fence, inside the outer fence Mild outlier Check the record and the measurement
Beyond an outer fence Extreme outlier Check the record and the measurement

A flag is a prompt to look, not a verdict. NIST advises understanding why an outlier appeared before considering elimination. Typical checks are a keying or unit error, an instrument fault, or a valid but unusual case. For what to do afterwards, see winsorizing vs trimming, and for outliers that distort a regression see Cook’s distance and influential observations.

Assumptions and common mistakes

  • Unstated quartile method. As shown above, it can change the flagged set.
  • Treating a flag as proof of error. The fence rule says a point is far from the middle half of the data, not that it is wrong.
  • Using Grubbs’ test on non-normal data. NIST describes Grubbs’ test as detecting a single outlier in a univariate data set that follows an approximately normal distribution; check normality first (see the Shapiro-Wilk test in R). For more than one suspected outlier, NIST recommends the Tietjen-Moore or generalized ESD test instead.
  • Dropping values after seeing their effect on the result. Decide the rule before looking at the outcome and apply it to every variable the same way.

Grubbs’ test in brief

The test statistic is G = max|Yi − Ȳ| / s, the largest absolute deviation from the sample mean in units of the sample standard deviation s. The null hypothesis is that there are no outliers; the alternative is exactly one outlier. In the two-sided test, H0 is rejected when G > ((N − 1)/√N) × √( t² / (N − 2 + t²) ), where t is the critical value of the t distribution with N − 2 degrees of freedom at significance level α/(2N).

How to report it

Report the rule, the quartile method, how many values were flagged and what you did. A template sentence in the numeric style typical of APA-formatted results:

Outliers were identified with the 1.5 × IQR rule (inclusive quartile method; Q1 = 15, Q3 = 22, IQR = 7). Two of 15 observations fell outside the fences (34 and 60). Both were checked against the source records and retained, and the analysis was repeated without them as a sensitivity check.

Adapt the last sentence to what you actually did. If you removed or modified values, say so and give the reason.

Frequently asked questions

How to find an outlier in statistics?

Sort the data, compute Q1, Q3 and the IQR, then flag values below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR. Values beyond 3 × IQR from the quartiles are extreme outliers.

How to calculate an outlier?

You do not calculate an outlier itself; you calculate fences and test each value against them. The step-by-step example above gives fences of 4.5 and 32.5 for the sample data.

How to find the outlier in a data set when there is only one suspect value?

If the data are approximately normal, Grubbs’ test checks a single suspect value formally. Otherwise use the IQR fences, which need no distributional assumption.

Is every outlier a mistake?

No. NIST notes that outliers often carry valuable information about the process or data collection, and that they should be investigated carefully before any decision to remove them.

Why do Excel and R give different outliers?

They can use different quartile definitions, which changes Q1, Q3 and so the fences. Name the method in your report.

Sources

Related on CASRAI: the interquartile range and five-number summary and z-scores in SPSS.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about How to Find an Outlier in Statistics: The IQR Rule, Step by Step

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.