Skip to content
simstat.com Statistics by simulation

Upper and Lower Fence: How to Find Outliers Using the IQR

The upper and lower fences mark how far a value may lie from the middle half of the data before it is flagged as a potential outlier. The lower fence is Q1 − 1.5 × IQR and the upper fence is Q3 + 1.5 × IQR, where Q1 and Q3 are the first and third quartiles and IQR = Q3 − Q1. Values beyond the outer fences, Q1 − 3 × IQR and Q3 + 3 × IQR, are extreme outliers. A value outside a fence is a reason to check it, not to delete it.

Last updated · by the simstat.com editorial team · How we write

The idea: a fence around the middle half

The quartiles split sorted data into four parts. The first quartile Q1 has about a quarter of the values at or below it, the third quartile Q3 about three quarters, and the interquartile range (IQR = Q3 − Q1) is the width of the middle half of the data. Illowsky and Dean (2023) describe it as “the spread of the middle half or the middle 50% of the data”.

The fences turn that width into a yardstick. Step out from each quartile by one and a half times the IQR and put up a fence: values inside are ordinary for this data set, values outside deserve a closer look. Each fence is an outlier boundary drawn from the data themselves, so it adapts to the scale and the spread of whatever you measure. Because the quartiles hardly move when a few extreme values are added, the boundary is not pushed outwards by the very points it is meant to catch. Hoaglin, Iglewicz and Tukey (1986) call it “a resistant rule for identifying possible outliers” and note that “as long as they are not too numerous, any outliers do not affect the location of the cutoffs”.

The lower fence formula and the upper fence

The NIST/SEMATECH e-Handbook (2012, section 7.1.6) defines four fences. The inner fences are

lower inner fence=Q1−1.5 IQR\text{lower inner fence} = Q_1 - 1.5\,\mathrm{IQR}
upper inner fence=Q3+1.5 IQR\text{upper inner fence} = Q_3 + 1.5\,\mathrm{IQR}

and the outer fences step out twice as far:

lower outer fence=Q1−3 IQR\text{lower outer fence} = Q_1 - 3\,\mathrm{IQR}
upper outer fence=Q3+3 IQR\text{upper outer fence} = Q_3 + 3\,\mathrm{IQR}

with IQR = Q3 − Q1. In this article, “the upper and lower fence” without a qualifier means the inner fences.

The handbook then classifies the points: “A point beyond an inner fence on either side is considered a mild outlier. A point beyond an outer fence is considered an extreme outlier.” A value exactly on a fence is not beyond it, and that is how our IQR calculator counts. OpenStax uses the inner fences only and speaks of a “potential outlier”, a value “less than (1.5)(IQR) below the first quartile or more than (1.5)(IQR) above the third quartile” (Illowsky and Dean, 2023).

Where Tukey’s rule comes from

The rule belongs to the box plot of exploratory data analysis. Langford (2006) writes that Tukey (1977) “introduced the concepts of box-and-whisker plot and five-number summary” in terms of upper and lower hinges, which are close to, but not always equal to, the quartiles. R’s boxplot.stats(), whose documentation cites Tukey’s book, draws whiskers to “the most extreme data point which is no more than” 1.5 times “the length of the box away from the box” (its default coef = 1.5) and returns the points beyond as outliers (R Core Team, 2024). Hoaglin, Iglewicz and Tukey (1986) state the rule with the lower and upper fourths (approximate quartiles), FL and FU, labelling as “outside” any observation below FL − 1.5(FU − FL) or above FU + 1.5(FU − FL). In a box plot with fences, the NIST e-Handbook (2012, section 1.3.3.7) draws points between the inner and outer fences as small circles and points beyond the outer fences as large circles.

How to find outliers using interquartile range

The steps are always the same: sort the data, find Q1 and Q3, subtract to get the IQR, compute the fences, and compare every value with them. The example below uses the weights of the 32 cars in R’s mtcars data, taken from the 1974 Motor Trend magazine (R Core Team, 2024), in thousands of pounds. They are the default data of our IQR calculator, so you can check every number there.

Worked example: fences for the weights of 32 cars

1. Sort. 1.513, 1.615, 1.835, 1.935, 2.14, 2.2, 2.32, 2.465, 2.62, 2.77, 2.78, 2.875, 3.15, 3.17, 3.19, 3.215, 3.435, 3.44, 3.44, 3.44, 3.46, 3.52, 3.57, 3.57, 3.73, 3.78, 3.84, 3.845, 4.07, 5.25, 5.345, 5.424.

2. Quartiles (median of halves). With n = 32, the median is the mean of the 16th and 17th values, (3.215 + 3.435) / 2 = 3.325. The lower half is x₁ to x₁₆, so Q1 = (x₈ + x₉) / 2 = (2.465 + 2.62) / 2 = 2.5425. The upper half, x₁₇ to x₃₂, gives Q3 = (x₂₄ + x₂₅) / 2 = (3.57 + 3.73) / 2 = 3.65.

3. IQR = 3.65 − 2.5425 = 1.1075, so 1.5 × IQR = 1.66125 and 3 × IQR = 3.3225.

4. Fences. Lower inner fence = 2.5425 − 1.66125 = 0.88125; upper inner fence = 3.65 + 1.66125 = 5.31125. Outer fences: 2.5425 − 3.3225 = −0.78 and 3.65 + 3.3225 = 6.9725.

5. Compare. The lightest car, 1.513, is far above the lower inner fence, so there are no low outliers. Two cars lie above the upper inner fence: the Chrysler Imperial (5.345) and the Lincoln Continental (5.424).

6. Classify. Both are below the upper outer fence of 6.9725, so the result is 2 mild outliers and 0 extreme ones. In a box plot the upper whisker stops at the heaviest car inside the fence, the Cadillac Fleetwood at 5.25.

R’s boxplot.stats() flags the same two cars, because for an even number of values its hinges equal the median-of-halves quartiles.

A hand-sized example with an extreme outlier

Example 2.13 of Illowsky and Dean (2023) gives 13 real estate prices in dollars. Sorted: 114,950; 158,000; 230,500; 387,000; 389,950; 479,000; 488,800; 529,000; 575,000; 639,000; 659,000; 1,095,000; 5,500,000. The median is 488,800, Q1 = 308,750 and Q3 = 649,000, so IQR = 340,250 and 1.5 × IQR = 510,375. The inner fences are −201,625 and 1,159,375, the values the book prints; as no price can be negative, no low outlier is possible. The upper outer fence is 1,669,750, so 5,500,000 is an extreme outlier, while 1,095,000 stays inside the inner fence.

How the quartile method changes the fences

There are many ways to compute quartiles. Langford (2006) notes that many authors use quartiles rather than Tukey’s hinges, “which is where the confusion arises, because of the many different definitions of the quartiles”. The methods differ only slightly, but a fence sits close to the edge of the data, where a small shift decides whether a point is flagged. The car weights with the three methods of our calculator:

MethodQ1Q3Upper fenceOutliers
Median of halves2.54253.655.311252
R type 7 / QUARTILE.INC2.581253.615.153133
QUARTILE.EXC / R type 62.503753.695.469380

The same data give 2, 3 or 0 outliers: type 7 adds the Cadillac Fleetwood (5.25) to the two cars found above, and type 6 flags none. The prices behave the same way: R’s type 7 quartiles, 387,000 and 639,000, put the upper inner fence at 1,017,000 and flag 2 prices, so 1,095,000 becomes an outlier too, and R’s boxplot.stats() agrees. NIST’s own example of 90 observations places the quartiles at the .25(N + 1)th and .75(N + 1)th ordered points, which is the type 6 method; our calculator reproduces its Q1 = 429.75, Q3 = 742.25 and upper inner fence of 1,211. No method is wrong, but a borderline point is only an outlier relative to a method, so say which one you used.

What the fences mean for a normal distribution

For a normal population with standard deviation σ, the quartiles lie 0.6745σ either side of the mean, so the IQR is 1.349σ. The inner fences then sit 2.698σ from the mean and the outer fences 4.721σ from it. The share of the population beyond the inner fences is 0.698%, about 0.70% (you can check it with our normal CDF calculator); beyond the outer fences it is about 2.3 in a million. Hoaglin, Iglewicz and Tukey (1986) report the same “population outside rate per observation (.7%)”.

Two further points matter. First, in a large sample from a perfectly normal population some points will fall outside the inner fences by chance alone: about 70 in a sample of 10,000. Second, small samples flag more, not fewer, points than the population rate suggests. In Hoaglin, Iglewicz and Tukey’s (1986) simulations of their rule on normal samples of 5 to 20 values, the share of samples with no point outside was only between 67% and 86%, and the expected share of points outside ranged from 8.6% down to 1.7%.

The fences need no assumption about the shape of the data, but they treat both tails alike, so on skewed data they flag the long tail routinely. Computed from the exact quartiles of each population:

PopulationBeyond the inner fencesBeyond the outer fences
Normal0.70%2.3 in a million
Exponential4.8%0.93%
Lognormal (log values standard normal)7.8%3.3%

In the skewed populations all of these points lie in the upper tail: they are part of the distribution, not errors.

What to do with an outlier

A point beyond a fence is a question, not an answer. Illowsky and Dean (2023) put it plainly: “Potential outliers always require further investigation.” They may be “errors or some kind of abnormality or they may be a key to understanding the data”. The NIST e-Handbook (2012, section 7.1.6) advises that outliers “should be investigated carefully” and that “before considering the possible elimination of these points from the data, one should try to understand why they appeared and whether it is likely similar values will continue to appear”.

In practice:

How to report it

Name the rule, the quartile method and what you did with the flagged values:

Car weights had a median of 3.325 thousand lb (IQR 1.1075; Q1 = 2.5425, Q3 = 3.65, n = 32; quartiles as medians of the lower and upper halves). With Tukey fences at Q1 − 1.5 × IQR and Q3 + 1.5 × IQR (0.88125 and 5.31125), two cars (5.345 and 5.424) were mild outliers and none lay beyond the outer fences at 3 × IQR. Both values were kept in the analysis.

A reader needs the multiplier (1.5, or 3 for the outer fences), the quartile method or software, whether a value on the fence counts as an outlier, and how many points were flagged, checked, corrected or excluded.

Common mistakes

Treating a flagged point as an error. The fences flag about 0.70% of a normal population and more of a skewed one. Being outside a fence says the value is unusual for these data, not that it is wrong.

Swapping in a standard-deviation rule as if it were the same thing. The rule “more than 2 SD from the mean” flags 4.6% of a normal population and “more than 3 SD” flags 0.27%, against 0.70% for the inner fences. The mean and SD are also pulled by the very values being judged: the single 5,500,000 price raises the SD of the 13 prices from 263,368 to 1,415,283, 5.4 times as large, while it moves the upper inner fence only from 1,054,375 to 1,159,375.

Using fences on skewed data without thinking. In an exponential population 4.8% of values lie beyond the inner fences, in a lognormal one 7.8%. For a right-skewed variable, describe the long tail rather than calling it a set of outliers, or look at it on another scale: for lognormal data, applying the fences to the logarithms flags 0.70%, the same share as for normal data.

Not saying which quartiles you used. As the table above shows, the method can change the count. Calculators, textbooks and software differ, so state the method.

Deleting outliers and recomputing until none are left. After a removal the quartiles shift and the fences move in. Drop the two flagged cars and the upper inner fence of the remaining 30 falls to 5.2275, so the Cadillac Fleetwood (5.25) is flagged next. Decide what to do with each flagged point on its merits, once.

Where to go next

To find the quartiles by hand first, see how to find IQR; the statistics hub collects our other guides. Our IQR calculator shows both sets of fences and lets you switch the quartile method. To see how much a statistic such as the median varies from sample to sample, read about the sampling distribution, and for intervals that do not assume normality start with what bootstrapping is.

References

  1. NIST/SEMATECH (2012). e-Handbook of Statistical Methods, section 7.1.6: What are outliers in the data?. National Institute of Standards and Technology (NIST Handbook 151, doi:10.18434/M32189).
  2. NIST/SEMATECH (2012). e-Handbook of Statistical Methods, section 1.3.3.7: Box Plot. National Institute of Standards and Technology (NIST Handbook 151, doi:10.18434/M32189).
  3. Illowsky, B. & Dean, S. (2023). Introductory Statistics 2e, Section 2.3: Measures of the Location of the Data. OpenStax, Rice University.
  4. Hoaglin, D. C., Iglewicz, B. & Tukey, J. W. (1986). Performance of Some Resistant Rules for Outlier Labeling. Journal of the American Statistical Association, 81(396), 991–999.
  5. Langford, E. (2006). Quartiles in Elementary Statistics. Journal of Statistics Education, 14(3).
  6. Statistics Online Support (n.d.). Outliers. The University of Texas at Austin (undated web page, accessed December 2026).
  7. R Core Team (2024). boxplot.stats: Box Plot Statistics (grDevices package documentation). R Foundation for Statistical Computing.
  8. R Core Team (2024). mtcars: Motor Trend Car Road Tests (datasets package documentation). R Foundation for Statistical Computing.

Try it

Related reading