# 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.

- Calculator id: `outlier-detection` · Category: Statistics & Probability (`statistics`) · Tool name: `detect_outliers`
- Canonical page: https://tttkmbb.com/statistics/outlier-detection · This document: https://tttkmbb.com/statistics/outlier-detection.md · JSON definition: https://tttkmbb.com/statistics/outlier-detection.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `values` | number_list |  | required | The data set (order does not matter). |
| `method` | enum: iqr \| z_score |  | optional, default "iqr" | Detection rule. The IQR rule is robust; the z-score rule uses the mean and SD, which the outliers themselves inflate. |
| `threshold` | number |  | optional | IQR 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. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `method_description` | string |  | The rule and threshold used. |
| `outliers` | number_list |  | Values outside the bounds, sorted ascending (first 60 when there are more). |
| `outlier_count` | integer |  | How many values were flagged. |
| `lower_bound` | number |  | Values below this are outliers. |
| `upper_bound` | number |  | Values above this are outliers. |
| `q1` | number |  | First quartile by linear interpolation (iqr method). |
| `q3` | number |  | Third quartile (iqr method). |
| `iqr` | number |  | Q3 − Q1 (iqr method). |
| `mean` | number |  | Mean of the full data set. |
| `std_dev` | number |  | Sample standard deviation of the full data set. |
| `cleaned_count` | integer |  | Number of values within the bounds. |
| `cleaned_mean` | number |  | Mean of the values within the bounds. |
| `cleaned_std_dev` | number |  | Sample standard deviation of the values within the bounds (needs ≥ 2 kept values). |

## 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.

## Data Sources

- NIST/SEMATECH e-Handbook of Statistical Methods, 7.1.6 What are outliers in the data? — https://www.itl.nist.gov/div898/handbook/prc/section1/prc16.htm (government, retrieved 2026-09-24)
- Wikipedia – Outlier — https://en.wikipedia.org/wiki/Outlier (reference, retrieved 2026-09-24)
- Wikipedia – Interquartile range — https://en.wikipedia.org/wiki/Interquartile_range (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/outlier-detection?values=…`
- `POST https://tttkmbb.com/api/v1/calculate/outlier-detection` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/outlier-detection · OpenAPI operationId `detect_outliers` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "outlier-detection", "inputs": {…}}`

## Example

- 1…9 and 50, IQR rule: inputs `{"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: inputs `{"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
```

## Limitations

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). 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. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Descriptive Statistics Calculator](https://tttkmbb.com/statistics/descriptive-statistics.md) — Full summary statistics of the same data.
- [Z-Score Calculator](https://tttkmbb.com/statistics/z-score.md) — Standardise a single value.
- [Percentile Calculator](https://tttkmbb.com/statistics/percentile.md) — Any percentile of the data by the same interpolation method.
