What the upper and lower fence are
The upper and lower fences are boundary values used to detect outliers in a dataset. They come from John Tukey's box-and-whisker method and are built entirely from the quartiles of your data. Any observation that falls below the lower fence or above the upper fence is treated as a potential outlier — a value far enough from the bulk of the data to deserve a second look.
The formula
The fences depend on three quantities: the first quartile (Q1, the 25th percentile), the third quartile (Q3, the 75th percentile), and the interquartile range (IQR), which is the spread of the middle half of the data:
- IQR = Q3 − Q1
- Lower fence = Q1 − 1.5 × IQR
- Upper fence = Q3 + 1.5 × IQR
The multiplier 1.5 defines the "inner fences", which flag mild outliers. Using 3.0 instead gives the "outer fences", which mark extreme or far-out outliers. Because the fences are built from quartiles rather than the mean and standard deviation, they are resistant to the very outliers they are meant to detect — a single huge value barely moves Q1 or Q3.
A worked example
Take the dataset 4, 5, 6, 7, 8, 9, 10, 11, 12, 40 (ten values). Using the exclusive method with linear interpolation, Q1 = 5.75 and Q3 = 11.25, so IQR = 5.5. The lower fence is 5.75 − 1.5 × 5.5 = −2.5, and the upper fence is 11.25 + 1.5 × 5.5 = 19.5. The value 40 sits well above the upper fence of 19.5, so it is flagged as an outlier; every other value falls inside the fences.
Why quartile methods vary
There is no single universal definition of a quartile. Textbooks and software differ in how they locate Q1 and Q3 — Tukey's hinges, the "inclusive" (median-included) method, and the "exclusive" method used here can each give slightly different quartiles for the same data, and therefore slightly different fences. This calculator uses the exclusive method with linear interpolation (rank = p × (n + 1)), the same convention used by many statistics courses and by spreadsheet functions like QUARTILE.EXC. Expect small differences if you compare against a tool that uses a different rule.