Outlier Detection Explanation Calculator
Detect outliers in a data set with the IQR fence, z-score or MAD method and see why each point is flagged, with mean and standard deviation before.
Outlier Detection Explanation Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: IQR: Outlier if x < Q1 - 1.5*IQR or x > Q3 + 1.5*IQR
Worked example โ 1 outlier detected (85) | Clean mean: 22.1 | Raw mean: 28.4
Formula
IQR: Outlier if x < Q1 - 1.5*IQR or x > Q3 + 1.5*IQR
The IQR method defines outliers as points beyond 1.5 times the interquartile range from the quartiles. The Z-Score method flags points more than a threshold number of standard deviations from the mean. The MAD method uses the median absolute deviation scaled by 1.4826 for robustness against the outliers themselves.
Worked Examples
Example 1: Temperature Sensor Readings
Problem:Readings: 22, 23, 21, 22, 85, 23, 22, 21, 23, 22. Detect outliers using IQR method (1.5x).
Solution:Sorted: 21, 21, 22, 22, 22, 22, 23, 23, 23, 85 Q1=22, Q3=23, IQR=1 Lower fence: 22 - 1.5(1) = 20.5 Upper fence: 23 + 1.5(1) = 24.5 Outlier: 85 (sensor malfunction) Clean mean: 22.1 vs raw mean: 28.4
Result:1 outlier detected (85) | Clean mean: 22.1 | Raw mean: 28.4
Example 2: Student Test Scores
Problem:Scores: 72, 75, 80, 78, 82, 76, 5, 79, 81, 77. Z-Score method with threshold 2.
Solution:Mean: 70.5, StdDev: 22.01 Z-score of 5: (5-70.5)/22.01 = -2.98 All others: z-scores between 0.07 and 0.52 (every remaining score sits above the mean) Only value 5 exceeds |z| > 2 Likely a student who missed most of the exam
Result:1 outlier detected (5) | Z-score: -2.98 | Clean mean: 77.78
Frequently Asked Questions
What is an outlier and why should I detect them?
An outlier is a data point that significantly differs from the rest of the dataset. Outliers can be caused by measurement errors, data entry mistakes, natural variation, or genuinely unusual observations. Detecting outliers is important because they can skew statistical analyses: a single extreme value can shift the mean dramatically, inflate standard deviation, and distort regression models. For example, in a dataset of salaries [40K, 45K, 50K, 55K, 2M], the mean is ~438K which misrepresents the typical salary. Outlier detection helps you decide whether to investigate, remove, or separately analyze these extreme values.
What is the difference between the IQR and Z-Score methods?
The IQR (Interquartile Range) method is a robust non-parametric approach that uses the middle 50% of the data. It calculates fences at Q1 - 1.5*IQR and Q3 + 1.5*IQR, and anything beyond those fences is flagged as an outlier. It works well for skewed distributions because it is based on percentiles rather than the mean. The Z-Score method measures how many standard deviations a point is from the mean and flags points beyond a threshold (typically 2 or 3). Z-Score assumes a roughly normal distribution and is sensitive to the very outliers it tries to detect (since outliers inflate the mean and standard deviation). For non-normal data, IQR or MAD methods are generally preferred.
What is the MAD (Median Absolute Deviation) method?
MAD is a robust measure of statistical dispersion that uses the median instead of the mean, making it resistant to outliers. It calculates the median of the absolute deviations from the data median. The formula is MAD = median(|xi - median(x)|). To make it comparable to standard deviation for normal distributions, MAD is multiplied by 1.4826 (the consistency constant). Points more than 3 scaled MADs from the median are flagged as outliers. MAD is considered the most robust of the three methods because neither the median nor the absolute deviations are affected by extreme values, avoiding the circular problem where outliers influence their own detection.
How do I choose the right threshold for outlier detection?
The threshold determines the sensitivity of outlier detection. For the IQR method, 1.5x IQR is the standard for mild outliers (used in box plots) and 3.0x IQR for extreme outliers. For Z-Score, a threshold of 2 flags about 5% of normally distributed data (more aggressive), while 3 flags about 0.3% (more conservative). For MAD, a threshold of 3 is standard. Start with default thresholds and adjust based on your domain knowledge: in financial data where extreme values are common, use higher thresholds; in manufacturing quality control where precision matters, use lower thresholds. Always investigate flagged outliers before removing them.
Should I always remove outliers from my data?
No. Removing outliers should be a deliberate, justified decision. There are three appropriate responses to outliers: (1) Investigate - the outlier may indicate a data entry error or measurement malfunction that should be corrected. (2) Keep - if the outlier represents genuine variation (like an unusually wealthy customer), removing it would bias your analysis. (3) Analyze separately - sometimes outliers represent a distinct subpopulation worth studying on its own. A common mistake is automatically removing outliers to get cleaner results, but this can introduce selection bias. Document any outlier removal and justify it. In some fields like fraud detection, the outliers are actually the most important data points.
Why does a z-score threshold of 3 flag nothing in a small sample?
Because the standardized deviation is bounded by the sample size. When the standard deviation is computed from the same n points, there is a hard ceiling on how large any absolute z-score can be, and that ceiling depends on which divisor the standard deviation uses. This tool divides the squared deviations by n, for which the ceiling is the square root of n minus 1: exactly 3.000 at ten observations and 3.162 at eleven. A threshold of 3 therefore cannot fire at all on ten points, however extreme one value looks, and only becomes usable from eleven points upward. Software that divides by n minus 1 instead has an even tighter ceiling of n minus 1 over the square root of n, which is 2.85 at ten points. Small samples belong to the IQR or MAD fences, which carry no such bound.
What are masking and swamping in outlier detection?
Masking is when outliers conceal themselves or each other. Since the mean and standard deviation are computed from contaminated data, one extreme value inflates the spread enough that its own z-score drops under the threshold, and two similar extremes hide each other outright. Swamping is the mirror failure: a far-out point drags the mean so far that ordinary observations get flagged instead. Both follow from a zero breakdown point, which is why the median and MAD, tolerating contamination up to half the sample, avoid the trap.
Why do the Q1 and Q3 shown here differ slightly from my spreadsheet?
Because there is no single definition of a quartile. This tool takes the order statistic sitting at the floor of one quarter and three quarters of the way through the sorted values, with no interpolation. Excel's QUARTILE.INC and R's default type 7 interpolate between the two neighbouring points, and Tukey's original hinges follow yet another convention. On large samples the gap is negligible, but on ten or twenty points it can move a fence enough to change whether a borderline value is flagged.
How should I handle right-skewed data such as incomes or response times?
Symmetric fences misfire on skewed data: with a long right tail the upper fence flags a steady stream of perfectly ordinary large values while the lower fence flags nothing at all. Two fixes are standard. Detect on a log scale, where multiplicative spread becomes roughly symmetric and the IQR rule behaves itself, or use an adjusted box plot that widens the fence on the heavy side in proportion to measured skewness. Quoting a high percentile as the cut is often more defensible than any fence.
Can these methods catch a point that is only unusual in combination with another variable?
No. IQR, z-score and MAD are all univariate and judge one column at a time. Someone recorded as 190 cm and 50 kg is unremarkable on either measurement alone, yet the pair is extreme. Catching that requires a multivariate approach such as Mahalanobis distance with a robust covariance estimate, or a model-based detector like local outlier factor or isolation forest. Run the univariate check first regardless, since it catches transcription errors that those methods will quietly absorb into the model.
References
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer ยท Editorial policy
Related Calculators
๐งฎColor Palette Balance AI
Calculate color palette balance ai with inputs, formulas, and instant results.
๐งฎEV Route Charge Planner Range AI
Calculate ev route charge planner range ai with inputs, formulas, and instant results.
๐งฎWork Break Pomodoro Planner AI
Calculate work break pomodoro planner ai with inputs, formulas, and instant results.
๐งฎ3D Print Time Support Estimator
Calculate 3d print time support estimator with inputs, formulas, and instant results.
๐งฎA B Test Significance Power Analyzer
Calculate a b test significance power analyzer with inputs, formulas, and instant results.
๐งฎAccessibility Contrast Optimizer WCAG
Calculate accessibility contrast optimizer wcag with inputs, formulas, and instant results.
๐งฎAd Spend Allocator Multi Channel ROAS
Calculate ad spend allocator multi channel roas with inputs, formulas, and instant results.
๐งฎAllergen Exposure Planner
Calculate allergen exposure planner with inputs, formulas, and instant results.