HomeStatistics & Probability › Outlier Detection Calculator

Outlier Detection Calculator

Flags outliers in a list of numbers using Tukey's interquartile-range fences (Q1 − 1.5·IQR, Q3 + 1.5·IQR) or a z-score threshold, and reports the bounds, the outliers and the mean and standard deviation of the remaining values.

When to use

You want to screen a data set for unusually large or small values before summarising it, or need the fences used by box plots.

Do not use when: You need a formal single-outlier test (Grubbs' test), the data are strongly skewed or multimodal (transform first), or you only want quartiles and summary statistics (use descriptive-statistics).

Formula

iqr: outlier if x < Q1 − threshold × IQR or x > Q3 + threshold × IQR (quartiles by linear interpolation, Excel PERCENTILE.INC). z_score: outlier if |x − mean| > threshold × s (sample SD)

Tukey's fences with multiplier 1.5 are the box-plot convention (NIST). The z-score rule cannot flag anything when the threshold exceeds (n − 1)/√n, the largest |z| a sample of size n can contain; a note is added in that case.

Inputs

ParameterTypeUnitRequiredDescription
valuesnumber_listyesThe data set (order does not matter).
methodenum: iqr | z_scoredefault iqrDetection rule. The IQR rule is robust; the z-score rule uses the mean and SD, which the outliers themselves inflate.
thresholdnumbernoIQR multiplier (1.5 = usual outliers, 3 = extreme outliers) or |z| cut-off (commonly 2, 2.5 or 3). Defaults: 1.5 for iqr, 3 for z_score. Range: > 0

Outputs

OutputTypeUnitDescription
method_descriptionstringThe rule and threshold used.
outliersnumber_listValues outside the bounds, sorted ascending (first 60 when there are more).
outlier_countintegerHow many values were flagged.
lower_boundnumberValues below this are outliers.
upper_boundnumberValues above this are outliers.
q1numberFirst quartile by linear interpolation (iqr method).
q3numberThird quartile (iqr method).
iqrnumberQ3 − Q1 (iqr method).
meannumberMean of the full data set.
std_devnumberSample standard deviation of the full data set.
cleaned_countintegerNumber of values within the bounds.
cleaned_meannumberMean of the values within the bounds.
cleaned_std_devnumberSample standard deviation of the values within the bounds (needs ≥ 2 kept values).

Example

1…9 and 50, IQR rule: {"values":[1,2,3,4,5,6,7,8,9,50],"method":"iqr"}{"outliers":[50],"outlier_count":1,"lower_bound":-3.5,"upper_bound":14.5,"q1":3.25,"q3":7.75,"iqr":4.5,"cleaned_count":9,"cleaned_mean":5}

10…18 and 100, z-score threshold 2: {"values":[10,11,12,13,14,15,16,17,18,100],"method":"z_score","threshold":2}{"outliers":[100],"outlier_count":1,"mean":22.6,"std_dev":27.3179,"lower_bound":-32.0358,"upper_bound":77.2358,"cleaned_mean":14,"cleaned_std_dev":2.7386}

GET https://tttkmbb.com/api/v1/calculate/outlier-detection?values=1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C50&method=iqr

Machine access

Sources

FAQ

Why did the z-score method miss an obvious outlier?

The outlier inflates the mean and SD used to judge it (masking). In a sample of 10 the largest possible |z| is 2.85, so a threshold of 3 can never trigger; use the IQR rule or a lower threshold.

Should I delete outliers?

Not automatically. Check for data-entry errors first; genuine extreme values may be the most important observations. Report results with and without them.

Related calculators