Percentiles, Quantiles and Z-Scores
A z score shows how many standard deviations a value is from its mean. Learn the formula, its uses in mean reversion and pairs trading, and the pitfalls.
A z score tells you how far a value is from its average, measured in standard deviations. A z score of 0 means the value equals the mean; a z score of +2 means it is two standard deviations above; minus 1.5 means one and a half below. Z scores let traders compare moves across assets with different volatilities and spot unusual readings. They are the backbone of many mean reversion, pairs trading and anomaly detection strategies.
The formula#
z = (x - mean) / standard deviation
The mean and standard deviation are usually calculated over a rolling window, such as the last 20 or 60 days. See Rolling and Expanding Windows.
Worked example#
Interpreting z scores#
If values were normally distributed:
| Z score | Share of values beyond this level (one side) |
|---|---|
| 1 | About 16% |
| 2 | About 2.3% |
| 3 | About 0.13% |
Market data has fat tails, so extreme z scores occur more often than these figures suggest. A "3 sigma" move might happen several times a year rather than once every few years. See Fat Tails and Normal Distribution.
Uses in trading#
| Use | Example | Lesson |
|---|---|---|
| Mean reversion signals | Buy when z falls below minus 2, sell when it rises above +2 | Mean Reversion |
| Pairs and spread trading | Z score of the spread between two related assets | Pairs Trading |
| Comparing moves | A 3% move in a calm stock vs a volatile one | |
| Bollinger Bands | Bands at ±2 standard deviations are a visual z score | Bollinger Bands |
| Factor scores | Standardising value or momentum signals across stocks | Combining Signals |
| Anomaly detection | Flagging unusual volume or spreads | Relative Volume |
Z scores of returns#
Instead of prices, traders often compute z scores of returns:
return z score = today's return / standard deviation of recent returns
A 4% drop in a stock with daily volatility of 1% is a minus 4 move, extreme; the same drop in a stock with 3% daily volatility is only about minus 1.3. Standardising this way puts moves on a common scale.
Cross sectional z scores#
Quantitative strategies often standardise a signal across many stocks on the same day: subtract the cross sectional mean and divide by the cross sectional standard deviation. This turns raw values, such as earnings yields, into comparable scores that can be combined. See Factor Investing Explained.
Pitfalls#
- Fat tails: extreme readings can keep getting more extreme.
- Trending markets: in strong trends, z scores can stay high or low for long periods; mean reversion trades fight the trend. See Trend Following.
- Window choice: different lookbacks give different z scores; short windows react fast but are noisy.
- Non stationary data: if the mean and volatility drift, z scores lose meaning. See Stationarity, Differencing and Unit Roots.
- Outliers in the window distort the mean and standard deviation. Robust versions use the median and median absolute deviation. See Outliers and Robust Statistics.
Frequently asked questions#
What is a z score?#
A measure of how many standard deviations a value is above or below its average.
How are z scores used in trading?#
To identify unusual prices or spreads for mean reversion and pairs trading, compare moves across assets and standardise signals.
Is a z score of 3 rare in markets?#
Less rare than the normal distribution suggests, because market returns have fat tails.
Next, learn how assets move together in Covariance and Correlation.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- Outliers and Robust StatisticsMath and Statistics
- CointegrationMath and Statistics
- Rolling and Expanding WindowsMath and Statistics
- Signal DiscoveryResearch and Backtesting
- Combining SignalsResearch and Backtesting
- Cleaning Market DataProgramming and Data