Outlier Detection Calculator Formula
Understand the math behind the outlier detection calculator. Each variable explained with a worked example.
Formulas Used
IQR
iqr_val = iqrLower Fence
lower_fence = q1 - 1.5 * iqrUpper Fence
upper_fence = q3 + 1.5 * iqrOutside Fences? (1=yes)
is_outlier = ((value < (q1 - 1.5 * iqr)) + (value > (q3 + 1.5 * iqr))) > 0 ? 1 : 0Distance Beyond Fence
distance = abs(value) > abs(q3 + 1.5 * iqr) ? abs(value - (q3 + 1.5 * iqr)) : abs(value) < abs(q1 - 1.5 * iqr) ? abs(value - (q1 - 1.5 * iqr)) : 0Variables
| Variable | Description | Default |
|---|---|---|
value | Value to Test | 95 |
q1 | Q1 (25th Percentile) | 30 |
q3 | Q3 (75th Percentile) | 70 |
iqr | Derived value= q3 - q1 | calculated |
How It Works
How to Detect Outliers Using the IQR Method
Formula
IQR = Q3 - Q1
Lower Fence = Q1 - 1.5 * IQR
Upper Fence = Q3 + 1.5 * IQR
Values below the lower fence or above the upper fence are flagged as potential outliers. The 1.5 multiplier is Tukey's convention. Using 3.0 instead identifies extreme outliers.
Worked Example
Q1 = 30, Q3 = 70. Is 95 an outlier?
value = 95q1 = 30q3 = 70
- 01IQR = 70 - 30 = 40
- 02Lower fence = 30 - 1.5*40 = 30 - 60 = -30
- 03Upper fence = 70 + 1.5*40 = 70 + 60 = 130
- 0495 is between -30 and 130, so it is NOT an outlier
- 05It would need to exceed 130 to be flagged
Ready to run the numbers?
Open Outlier Detection Calculator