You are cleaning a dataset for an analysis project, and a few extreme values threaten to ruin your model. Relying on gut feeling to drop these data points leaves your methodology open to bias. You need an objective, mathematical justification to decide whether a number is a genuine anomaly or a valid piece of extreme data.
Why standard deviation fails on skewed data
Many analysts instinctively reach for the standard deviation and the mean to spot unusual data points. This approach works well on a neat, symmetrical bell curve. Real-world data, however, is rarely symmetrical.
When a dataset is skewed—such as income distributions or website traffic—a single massive value pulls the arithmetic mean toward itself. Because the mean and standard deviation are sensitive to extreme values, the anomaly itself distorts the yardstick you are using to measure it.
The Interquartile Range (IQR) solves this problem. Because it focuses on the middle 50 percent of the data and uses the median, it remains unaffected by extreme highs or lows.
The mechanics of Tukey's fences
Tukey's Fences Formula
- Q_1
- First quartile (25th percentile)
- Q_3
- Third quartile (75th percentile)
- IQR
- Interquartile range
The IQR method relies on dividing ordered data into four equal parts using quartiles.
- First quartile (): The 25th percentile, marking the boundary where a quarter of the data falls below it.
- Third quartile (): The 75th percentile, marking the boundary where three-quarters of the data falls below it.
- Interquartile range (): The span between the third and first quartiles, calculated as .
To establish where normal data ends and outliers begin, John Tukey introduced the concept of fences using a 1.5 multiplier.
- Lower fence:
- Upper fence:
Any data point falling below the lower fence or above the upper fence is flagged as an outlier. For deeper datasets, you can spot these 'odd ones out' with an interactive box plot or check these metrics rapidly using the Basic Statistics Calculator to view dispersion parameters in real time.
Step-by-step outlier detection
Outlier Detection Steps
- 1Sort dataset
Arrange all numerical observations from the lowest value to the highest value.
- 2Find median and quartiles
Determine the median to split the data, then locate Q1 and Q3.
- 3Calculate the IQR
Subtract the value of Q1 from Q3 to find the middle spread.
- 4Compute fence boundaries
Multiply IQR by 1.5 and apply to Q1 and Q3 for lower and upper bounds.
- 5Identify flagged points
Scan the dataset for any values that sit past the fence thresholds.
- Sort the dataset in ascending order: Arrange all numerical observations from the lowest value to the highest value.
- Find the median and quartiles: Determine the median to split the data, then locate (the median of the lower half) and (the median of the upper half).
- Calculate the IQR: Subtract the value of from to find the middle spread.
- Compute the fence boundaries: Multiply the IQR by 1.5, then subtract it from for the lower bound and add it to for the upper bound.
- Identify flagged points: Scan the sorted dataset for any values that sit past the lower or upper fence thresholds.
When dealing with large datasets containing hundreds of rows, manual sorting leads to arithmetic errors. Running your numbers through an in-browser statistics tool lets you inspect dispersion metrics instantly without writing custom scripts.
The decision framework: What to do after finding outliers
Finding an outlier is only the first step. Deleting it automatically destroys valuable information if you do not understand its origin.
First, investigate whether the outlier stems from a data entry error. If a user typed 9,999 instead of 99 due to a keystroke slip, correct or remove it immediately.
Second, check for measurement or instrument malfunctions. If a sensor jammed and recorded zero or a maximum voltage limit for an hour, those readings are artificial noise.
Third, evaluate if the outlier represents genuine extreme variance. In financial fraud detection or rare disease studies, the outliers are often the exact data points you need to analyze. In these cases, keeping the data, running robust statistics, or applying a logarithmic transformation is safer than deletion.
Preventing distortion in future analyses
Outliers often reveal structural issues in how data is collected. Standardizing entry forms, adding input validation ranges, and setting up automated range checks prevent clerical mistakes before they reach your analysis pipeline. Whenever you encounter recurring extreme values, document the context so your team understands why certain points were kept or excluded in subsequent reports.