ThisCalculator

Construction

Upper and Lower Fences: Formula and Example

Updated · Standard formula, shown below

Lower fence -3.50
Upper fence
12.50
Result
Interquartile range
4.00
Result
Data values
8 values
You entered

Numbers separated by commas, spaces or new lines.

Upper and Lower Fences: Formula and Example

Upper and lower fences are calculated from the first and third quartiles: subtract 1.5 times the interquartile range (IQR) from Q1 for the lower fence, and add it to Q3 for the upper fence. Enter a data list to calculate both fences and the quartiles used to find them; values outside the fences are potential outliers, not automatically errors.

Formula

The standard Tukey-fence formulas are:

  • IQR = Q3 − Q1
  • Lower fence = Q1 − 1.5 × IQR
  • Upper fence = Q3 + 1.5 × IQR

Here, Q1 is the first quartile, or 25th-percentile boundary; Q3 is the third quartile, or 75th-percentile boundary; and IQR is the spread of the middle half of the data. The factor 1.5 is the conventional multiplier used for the usual outlier rule. Fences have the same units as the data: for example, if observations are measured in centimetres, both fence values are in centimetres. The calculator accepts a list of numbers and uses its quartile calculation to produce the results.

Worked Example

Using the calculator’s default values, the sorted data are 1, 2, 3, 4, 5, 6, 7, 8. With an even number of observations, the median is the mean of the middle pair, 4 and 5, or 4.5. The calculator’s quartile convention takes the median of each half: the lower half is 1, 2, 3, 4, and the upper half is 5, 6, 7, 8.

  1. Q1 = (2 + 3) ÷ 2 = 2.5.
  2. Q3 = (6 + 7) ÷ 2 = 6.5.
  3. IQR = 6.5 − 2.5 = 4.
  4. Lower fence = 2.5 − (1.5 × 4) = −3.5.
  5. Upper fence = 6.5 + (1.5 × 4) = 12.5.

Thus, the calculator returns a lower fence of −3.50 and an upper fence of 12.50. None of the eight listed values falls outside that interval.

How to Use the Fences

Compare each observation with the two fence values. A value below the lower fence or above the upper fence is commonly flagged as a potential outlier. A value equal to a fence is not beyond it, so under the usual rule it is not flagged. The fences define thresholds; they are not necessarily observed data values, and they do not tell you which observation is closest to the middle.

For example, in the default list, a value of 13 would be above the upper fence of 12.5, while a value of 12 would not. The rule identifies unusual distance relative to the central spread. It does not establish that a value was entered incorrectly or should be deleted. Check the original record, measurement process, and context before deciding how to handle a flagged point.

The rule is useful for exploratory data analysis and for describing potential outliers on a box plot. Box plots often draw whiskers to the most extreme observed values still within the fences, and show more distant observations individually. A whisker therefore does not always end exactly at a fence.

Quartile Conventions and Data Preparation

Quartiles are not calculated identically by every statistical program or textbook, particularly for small samples. One common hand-calculation method splits the sorted observations into lower and upper halves and takes each half’s median. Other methods interpolate between observations or use a percentile algorithm. These choices can produce slightly different Q1 and Q3 values, which in turn change the fences.

To make a result reproducible, sort the data, state the quartile convention, and use the same method whenever comparing results. This calculator uses the quartile functions shown in its list calculation convention; for a small list, check that convention if matching a particular class, report, or software package matters.

Before calculating, also check that the list contains the intended observations and that all values use compatible units. Do not mix, for example, centimetres and metres without converting them first. Missing entries should not be replaced with zero unless zero is genuinely the measured value. A zero can substantially alter the quartiles and fences.

Common Misinterpretations and Limits

  • A fence is not a data boundary. The calculated threshold may not appear in the dataset.
  • “Potential outlier” does not mean “bad data.” A legitimate rare observation can lie beyond a fence.
  • The rule is not a significance test. It does not calculate a probability that a point is wrong or prove that a distribution is unusual.
  • Skew and small samples matter. In strongly skewed data, a valid tail observation may be flagged. With very few observations, quartile estimates can be especially sensitive to the chosen convention.
  • Rounding should come last. Keep full precision when comparing observations with fences, then round values for display. Rounding first can change whether a value appears to cross a threshold.

Because the IQR is resistant to the size of extreme observations, these fences are less affected by a single extreme value than rules based on the mean and standard deviation. That resistance is useful, but it does not make the method appropriate for every distribution or every decision. For a formal analysis, consider the data’s shape, how observations were collected, and the consequences of treating a point differently.

Frequently Asked Questions

What is the formula for upper and lower fences?
Calculate IQR = Q3 − Q1. Then calculate the lower fence as Q1 − 1.5 × IQR and the upper fence as Q3 + 1.5 × IQR.

What does a value outside a fence mean?
It is flagged as a potential outlier under the 1.5-IQR rule. The flag is a prompt to investigate, not proof of an error or an instruction to remove the value.

Can the lower fence be negative?
Yes. The formula can produce a negative lower fence even when the data cannot be negative. In that case, no nonnegative observation can fall below that fence, but the formula itself is unchanged.

Are fences the same as whiskers on a box plot?
No. Fences are calculated thresholds. In a common box-plot convention, whiskers extend to the most extreme data points within those thresholds, while points beyond them are plotted separately.

Why do different calculators give different fences?
They may use different methods to calculate Q1 and Q3, especially for small or even-sized datasets. Check the quartile convention and ensure the same data and units were entered.

Related

Formula used
list data | Data values | 1, 2, 3, 4, 5, 6, 7, 8
out lower | Lower fence | - | q1(data) - 1.5 * (q3(data) - q1(data)) | 2
out upper | Upper fence | - | q3(data) + 1.5 * (q3(data) - q1(data)) | 2
out iqr | Interquartile range | - | q3(data) - q1(data) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.