Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 1: Descriptive statistics

Outliers: find them and decide what to do

The register at "Mama John's" sees ordinary receipts — and suddenly an order for twenty pizzas: an office party. One such value can flip the mean, inflate the variance and ruin a model. Yet an outlier is not always "an error": sometimes it is the most valuable thing in the data. On the right — the same data in three ways (points, histogram, box plot); we'll go step by step through how to spot an outlier and how to deliberately choose what to do with it.

shape histogrambox plotpoints · mean and median
▏ mean 47▏ median 28Q1–Q3: 21–41outlier: 280
The real outlier stays. It inflates the mean, and the box plot flags it as a dot past the whisker — for a "typical" value use the median. Right when the outlier matters in itself.

One outlier drags everything: the mean is ≈ 47, the histogram stretches into a long tail, a dot appears past the whisker on the box plot. The median and the Q1–Q3 box barely move — they are robust. First understand the outlier's nature (error or reality), then pick the action — and document it.

An outlier is a value that has broken far away from the bulk. The widget shows the same data in three ways at once: points at the bottom (the green mean has drifted toward the outlier, the yellow median stayed with the group); a histogram in the middle (the outlier is a lonely bar far to the right — a long tail); a box plot on top (a red dot flying past the whisker). One extreme moves the mean, but barely touches the median and the box.

How it is used
What decision this changes

A decision about an outlier is a decision about its nature: a data error — fix it; a real "big customer" — keep it and change the method, not the data.

Before any analysis, an analyst draws a box plot and a histogram and checks the outliers: a lonely bar in the tail and a dot past the whisker are visible at once. Then separates: input errors get fixed, real extremes get handled deliberately (robust measures, capping, log), and the decision is documented so the analysis stays reproducible.

Sometimes the outlier IS the goal: a fraudulent transaction, a failing server, anomalous demand. Then you do not remove it — you hunt for it; a whole field of anomaly detection is built on this.

Where it shows up

In money and response times outliers are a fact of life, not a rarity: there is always a pair of giant orders or hung requests. That is why medians and percentiles are the default there, and spread is read off the box plot.

In machine learning uncleaned erroneous outliers drag the model toward themselves (especially with squared error), while real ones are, on the contrary, informative; confusing the two is expensive.

Definitions
Outlier
A value visibly detached from the bulk of the data.
In plain words: a point living apart from the rest of the data.
Box plot (box-and-whiskers)
A compact summary of the data: a box from Q1 to Q3 with a median line inside, whiskers to the edges of ordinary values, and separate dots for outliers. It lets you see the center, spread and stray values in one glance.
In plain words: five numbers instead of the whole pile: the box is the central half, whiskers are the edges, dots are outliers.
The 1.5·IQR rule
The outlier boundary: a value farther than 1.5 box-widths (1.5·IQR, where IQR = Q3 − Q1) from Q1 or Q3. It relies on robust quartiles rather than the mean, so it holds even on tailed data.
In plain words: farther than one and a half "boxes" from the middle — an outlier candidate.
Winsorizing (capping)
Clip extreme values to a threshold (e.g. p1/p99) while keeping the observation itself in the data.
In plain words: do not throw it out — trim it to an allowed ceiling.
Log transform
Take the logarithm to compress the long tail and pull the data toward symmetry.
In plain words: squeezes huge values so the tail stops driving the analysis.
When the method lies (assumptions)

The 1.5·IQR rule and the |z|>3 threshold (z is the distance from the mean in standard deviations — more on this in the normal distribution lesson) are heuristics, not truth: different distributions have different "normal" shares of outliers. On heavily skewed data 1.5·IQR will flag many perfectly normal tail values.

Removing outliers changes conclusions and easily turns into result-fitting. Every removal must be justified by the nature of the data and documented.

Next →
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words — real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel