Robust Scaling with Median and IQR
Robust scaling rescales a feature using the median and interquartile range instead of the mean and standard deviation, so a handful of extreme outliers no longer distort the scale for every other observation.
Prerequisites: Standardization vs Min-Max Scaling, Robust Summary Statistics: Median and MAD
Standardization rescales a feature using its mean and standard deviation, but both of those statistics are themselves distorted by extreme outliers — a single wild value can inflate the standard deviation enough to compress every other observation's z-score toward zero, hiding real variation among the normal, non-outlier data. Robust scaling fixes this at the source by replacing the mean and standard deviation with statistics that barely move when a few extreme values are present: the median and the interquartile range.
The transformation, in words
Robust scaling centers a feature on its median (, the middle value in sorted order) rather than its mean, and scales it by the interquartile range (, the width of the middle 50% of the data) rather than the standard deviation:
In plain English: instead of asking "how far is this value from the average, measured in units of how spread-out everything typically is," robust scaling asks "how far is this value from the typical middle value, measured in units of how spread out the typical middle half of the data is" — deliberately ignoring the bottom and top quarters (where outliers live) entirely when defining the scale.
Why this resists outliers where standardization doesn't
The median is the middle value in sorted order — moving one extreme value further out doesn't change which observation sits in the middle, so the median is essentially unaffected. The IQR is defined entirely by the 25th and 75th percentiles, which live comfortably inside the bulk of "normal" data. Both the mean and the standard deviation, by contrast, are sums over every observation, so a single sufficiently extreme value can move them arbitrarily far — the standard deviation is even more sensitive, since it squares deviations from the mean, amplifying the effect of anything far out.
Worked example: the same data, three ways
Take the P&L data from earlier: sorted values ($000s) , with median , , , so . A normal-looking value of robust-scales to . Now suppose the outlier were even more extreme — $400,000 instead of $40,000. The median, , and are completely unchanged, so still robust-scales to exactly . Standardizing the same data, the far larger outlier drags the mean up and inflates the standard deviation substantially, so the standardized value for shifts noticeably — the "normal" data's scaled representation changed purely because of how extreme one unrelated point became, which is exactly the instability robust scaling avoids.
Where standardization (shown conceptually in the explorer above, built around mean and standard deviation) is thrown off by a heavy tail, robust scaling deliberately looks only at the middle of the distribution — the box in a box plot, not the whiskers or the outlier dots — to define its notion of "typical spread."
What this means in practice
Robust scaling is the safer default whenever a feature is known or suspected to contain a small number of extreme values that shouldn't be allowed to distort how every other observation is represented — trade sizes, P&L, volume spikes, or any financial quantity with fat tails. The tradeoff is that robust scaling deliberately throws away information about exactly how extreme the extremes are (an outlier that's 10x normal and one that's 1000x normal can end up close together after robust scaling, since both are just "far from the box"), so if the magnitude of extreme values itself carries signal, some information is lost relative to a method that preserves it.
Robust scaling replaces the mean and standard deviation with the median and interquartile range, so a feature's rescaled values depend only on the typical middle of the distribution and are essentially unaffected by how extreme a handful of outliers happen to be. This makes it the more reliable default for fat-tailed financial features, at the cost of compressing information about just how extreme the extremes really are.
Robust scaling doesn't remove outliers or cap their values — an extreme point still gets a correspondingly extreme (if bounded-in-comparison) scaled value; it just prevents that point from distorting the scale used for everyone else. Don't confuse "robust to outliers distorting the scale" with "outliers are handled" — you may still need a separate winsorization or capping step depending on the model.
Related concepts
Practice in interviews
Further reading
- Rousseeuw & Leroy, Robust Regression and Outlier Detection, ch. 1