What Is the Upper and Lower Fence Calculator?
A fence is a cutoff drawn far enough out that crossing it means something. Tukey got the idea from box plots: the box spans the interquartile range, and whiskers reaching 1.5 times that width from the box mark the values that no longer look like the bulk of the data. Where the whiskers stop becomes the fence.
The useful property is that fences are computed from the middle half of the data and ignore the tails. A value ten times larger than everything else cannot drag the fence out to meet itself, so it is judged against where the ordinary data sits rather than against its own influence.
How Does the Upper and Lower Fence Calculator Work?
Sort the values and find the first and third quartiles, Q1 and Q3. Half the data lies between them, and their difference is the interquartile range, or IQR.
Multiply the IQR by the multiplier. The default 1.5 gives the inner fences; the outer fences use 3.
Add that amount to Q3 for the upper fence and subtract it from Q1 for the lower fence. Anything above the upper fence or below the lower fence is flagged.
For median absolute deviation fences, take the median, measure the absolute deviation of every value from it, and take the median of those deviations. Scaling by 1.4826 makes this a consistent estimate of the standard deviation for normal data, and the fences are that scaled MAD multiplied by k, measured out from the median.
For standard deviation fences, take the mean and the standard deviation, and measure k standard deviations out in both directions.
Upper and Lower Fence Calculator Formula & Variables
The core mathematical equation utilized by this calculator is expressed as:
Variable Definitions
| Symbol | Variable Meaning & Units |
|---|---|
| Q1 | the first quartile: a quarter of the values lie below it |
| Q3 | the third quartile: a quarter lie above it |
| IQR | the interquartile range, the width of the middle half |
| k | the multiplier, 1.5 for the inner fences and 3 for the outer |
| MAD | the median absolute deviation from the median |
| σ | the standard deviation |
The interquartile range spans the middle half of the data. Multiplying it by a constant and adding or subtracting it from the quartiles places the fences at k IQRs from the middle of the distribution. The outer pair simply uses k = 3, which is far enough out that only values with something genuinely wrong behind them reach it.
How to Use the Upper and Lower Fence Calculator
- Paste in up to 50 values. The order does not matter, since every method sorts internally.
- Leave the basis on Tukey fences with a multiplier of 1.5, which is the convention. A multiplier of 3 gives the outer pair on its own.
- If your reference book uses hinge quartiles, switch the quartile definition so the fences agree with it.
- Switch to the median absolute deviation when the data is skewed or has a long tail; the fences then stay put no matter how many extreme values there are.
- Read the table of values. Each one is labelled as inside the fences, above or below a fence, or beyond the outer pair, and the count of flagged values appears in the summary.
Step-by-Step Example Calculation
Twelve routine readings with one extreme value
Input Values:
Understanding Your Result
With Q1 = 23.75, Q3 = 28 and an IQR of 4.25, the 1.5 fences are 17.375 and 34.375 and the outer pair is 11 and 40.5.
The fences are not a range your data should fill. The middle half of any roughly symmetric sample falls between Q1 and Q3, and the 1.5 fences extend beyond that by half an IQR on each side.
A count of zero flagged values is not proof the data is clean, only that nothing sits beyond 1.5 IQRs. Errors small enough to hide inside the interquartile range are invisible to fences.
If switching from Tukey to MAD fences changes the answer, the data is skewed enough that the choice of centre matters, and the MAD result is the one to trust.
Fences at zero for the IQR mean at least half the values are identical, and then every fence collapses onto the quartiles and every other value is flagged.
Factors That Affect the Result
- The multiplier. Moving from 1.5 to 3 widens the fence band by a factor of two and takes roughly three thousand times fewer points in a normal sample, from about 0.7% to 0.27%.
- The quartile definition. Interpolation and hinges differ on lists whose length is not a multiple of four, and the difference grows with the multiplier.
- List length. Quartiles of a short list are averages of very few values, so adding or removing one point can move a fence noticeably.
- The basis of the spread. The interquartile range ignores the tails, the MAD ignores them too, and the standard deviation is built from them, so the same data gives different fences under each.
- Any extreme value. It barely affects Tukey and MAD fences, but it inflates a standard deviation enough to widen those fences around itself.
When Should You Use This Calculator?
- Screening a measurement column for transposed digits, stuck sensors and impossible readings before running any analysis on it.
- Setting up a box plot, where the whiskers need to stop somewhere and the 1.5 IQR rule is the usual choice.
- Checking whether a newly collected batch is consistent with the process that produced the earlier ones.
- Reviewing a distribution for a long tail before assuming normality, since fences show quickly whether the tails are thin or heavy.
- As a sanity check on other statistics, because an outlier that survives into a mean will distort everything downstream of it.
Assumptions & Limitations
- The fences are calibrated for roughly symmetric, unimodal data. On a skewed distribution they will flag the legitimate upper tail.
- The 1.5 and 3 multipliers come from hand-drawn box plots rather than from an optimisation, so they are conventions with no sharp justification.
- Only one value can move a quartile when the list is short, which makes fences on tiny samples unstable rather than wrong.
- A fence flags a difference without explaining it. Cause, stage of production and intent all have to come from outside the data.
- Values that are genuine cannot be fenced away. Deleting them to satisfy a fence destroys information and can bias whatever the data was collected for.
Frequently Asked Questions
Calculation Accuracy & Reference Note
The values are sorted and the quartiles, medians and absolute deviations are accumulated in double precision, which carries about 15 significant digits, so the fences are exact to far more digits than are displayed. Lists longer than 50 values are rejected rather than silently truncated, and a zero median absolute deviation is reported as degenerate rather than divided through.
Standard Reference: Tukey, J.W. (1977), Exploratory Data Analysis. Addison-Wesley. Iglewicz, B. and Hoaglin, D.C. (1993), How to Detect and Handle Outliers, Volume 16 of ASQC Quality Press. NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.5 on box plots.