Overview
Two samples can have the same mean and the same variance and still behave very differently. In one, the variance comes from many moderate deviations. In the other, most values sit close to the mean and a few lie very far out. Kurtosis tells these apart. It raises each standardised deviation to the fourth power, so values far from the mean count enormously and values near it count almost nothing. A normal distribution scores 3, and the excess form subtracts 3 so that normal reads as zero. Heavier tails than normal are called leptokurtic, lighter tails platykurtic, and normal-like tails mesokurtic. It describes tail weight, not how pointed the peak is.
A short history
Karl Pearson introduced kurtosis in 1905, together with the terms leptokurtic, mesokurtic and platykurtic, to describe how a frequency curve departs from the normal curve beyond its skewness. It was long taught as a measure of peakedness. Later writers, including Peter Westfall in 2014, showed that it really measures the weight of the tails: how much of the variance is due to rare, extreme values.
How it works
- Drop NaN entries and subtract the mean from every value.
- Compute the second central moment, the mean of the squared deviations, and the fourth, the mean of the deviations to the fourth power.
- Divide the fourth moment by the square of the second. This is Pearson's kurtosis, which is 3 for a normal distribution.
- Subtract 3 to get the excess kurtosis when fisher is true.
- When bias is false, apply the sample-size correction, which needs at least four values.
- Classify: leptokurtic if the excess is above tolerance, platykurtic if it is below minus tolerance, mesokurtic in between.
- With describe, divide the corrected estimate by its standard error to get a z score for whether the tails differ from a normal's.
Watch out for
- The estimate is dominated by the most extreme points, because deviations are raised to the fourth power. One outlier can move it from negative to strongly positive.
- It needs a few hundred observations to be stable. On small samples the value changes a lot from one sample to the next.
- High kurtosis does not mean a sharp peak. A distribution can be flat in the middle and still have heavy tails.
- Software differs on whether it reports excess kurtosis or Pearson's, so a value of 3 can mean normal in one tool and heavy tails in another.
- The standard error used for the z score assumes a normal sample, so the z score is a test of normal tails and nothing more general.
Use cases
When to use it
When outliers and tail risk matter: checking the normality assumption before a test, choosing a loss that tolerates extreme errors, or judging how far a mean can be trusted.
In industry
- Financial risk
- Risk analysts measure the kurtosis of daily returns because fat tails mean that large losses happen far more often than a normal model predicts.
- Machine condition monitoring
- Vibration signals from bearings are tracked by kurtosis: sharp impacts from an early defect raise it before the overall vibration level changes.
- Signal processing
- Independent component analysis uses kurtosis as a measure of how far a signal is from Gaussian when separating mixed sources.
Choosing it: what must hold
- A numeric variable with a reasonably large sample, since the fourth moment is very sensitive to a few values.
- Clarity about whether you report kurtosis, which is 3 for a normal distribution, or excess kurtosis, which is 0.
- An interest in tail behaviour and outlier proneness, not in the height of the peak.
When to choose something else
| If | Use instead |
|---|---|
| The sample is small or you need a robust measure of tails | Quantile based summaries from quartiles and IQR, or a count of points beyond the fences |
| The question is about asymmetry, not tail weight | Skewness, covered in distribution analysis |
| You need a formal check against the normal distribution | A normality test and Q-Q plot from distribution analysis |
Math foundations
Central moments
The average -th power of the deviations from the mean. is the population variance. gives heavy weight to values far from the mean.
Excess kurtosis
Dividing by removes the unit and the scale, so only the shape remains. Subtracting 3 makes a normal distribution score zero.
Sample-size corrected estimate
The plain estimate runs low on small samples. This version is unbiased for normal data and is what most statistics packages report.
Standard error under normality
How much varies from sample to sample when the data really are normal. For large it is close to .
The z score
The corrected estimate in units of its standard error. A size beyond about 2 suggests the tails differ from those of a normal distribution.
Symbols
- the i-th value
- the mean of the values
- number of values
- second and fourth central moments
- the plain (biased) excess kurtosis
- the sample-size corrected excess kurtosis
- the corrected estimate divided by its standard error
Worked by hand
Five values: 1, 2, 3, 4, 5. The mean is 3 and the deviations are -2, -1, 0, 1, 2.
The excess kurtosis is -1.3. Evenly spread values have no extreme points relative to their spread, so they are platykurtic, with lighter tails than a normal distribution.
Visual example
Loading the example.
Try this
- Switch from the flat shape to the heavy tails and watch the excess kurtosis go from negative to strongly positive.
- On the normal shape, add one value 6 standard deviations out: a single point turns the sample leptokurtic.
- Draw new samples at n = 20 and see how far the estimate jumps from one draw to the next.
Code sample
import numpy as np
from impl import Kurtosis
from config import KurtosisConfig
k = Kurtosis(KurtosisConfig(fisher=True, bias=True))
print(k.kurtosis([1, 2, 3, 4, 5])) # -1.3
print(k.classify(np.random.default_rng(0).laplace(size=10_000))) # leptokurtic
print(k.describe(np.random.default_rng(0).normal(size=1000)))Read the implementation (83 lines)
"""Kurtosis: how heavy the tails of a distribution are compared with a normal distribution.
NumPy only. Excess kurtosis is m4 / m2^2 - 3, where m2 and m4 are the second and fourth central moments. Positive
means heavier tails and more outliers than a normal (leptokurtic), negative means lighter tails (platykurtic),
near zero means normal-like tails (mesokurtic).
"""
from __future__ import annotations
import math
import numpy as np
try:
from .config import KurtosisConfig
except ImportError: # run from the template's own folder
from config import KurtosisConfig
class Kurtosis:
"""Sample kurtosis, its standard error and its lepto/meso/platykurtic class."""
def __init__(self, config: KurtosisConfig | None = None) -> None:
self.config = config or KurtosisConfig()
@staticmethod
def _clean(values) -> np.ndarray:
x = np.asarray(values, dtype=float).ravel()
x = x[~np.isnan(x)]
if x.size < 2:
raise ValueError("at least two values are needed")
return x
def excess(self, values) -> float:
"""Excess kurtosis (normal = 0), with or without the sample-size correction set by config.bias.
values: array-like, flattened; NaN entries are dropped.
"""
x = self._clean(values)
n = x.size
deviations = x - x.mean()
m2 = float(np.mean(deviations**2))
if m2 == 0:
raise ValueError("kurtosis is undefined for constant data")
g2 = float(np.mean(deviations**4)) / m2**2 - 3.0
if self.config.bias:
return g2
if n < 4:
raise ValueError("the bias-corrected estimate needs at least four values")
return (n - 1.0) / ((n - 2.0) * (n - 3.0)) * ((n + 1.0) * g2 + 6.0)
def kurtosis(self, values) -> float:
"""Kurtosis in the convention chosen by config.fisher: excess (normal = 0) or Pearson (normal = 3)."""
excess = self.excess(values)
return excess if self.config.fisher else excess + 3.0
def classify(self, values) -> str:
""""leptokurtic" (heavy tails), "platykurtic" (light tails) or "mesokurtic" (normal-like)."""
excess = self.excess(values)
if excess > self.config.tolerance:
return "leptokurtic"
if excess < -self.config.tolerance:
return "platykurtic"
return "mesokurtic"
@staticmethod
def standard_error(n: int) -> float:
"""Standard error of the corrected excess kurtosis G2 for a normal sample of size n (n >= 4)."""
if n < 4:
raise ValueError("n must be at least 4")
return math.sqrt(24.0 * n * (n - 1.0) ** 2 / ((n - 3.0) * (n - 2.0) * (n + 3.0) * (n + 5.0)))
def describe(self, values) -> dict:
"""Kurtosis, excess kurtosis, class, sample size and (for n >= 4) the standard error and z score.
The z score is G2 divided by its standard error; beyond about 2 in size the tails differ from a normal's.
"""
x = self._clean(values)
out = {"n": int(x.size), "kurtosis": self.kurtosis(x), "excess": self.excess(x), "kind": self.classify(x)}
if x.size >= 4:
corrected = Kurtosis(KurtosisConfig(fisher=True, bias=False, tolerance=self.config.tolerance)).excess(x)
out["standard_error"] = self.standard_error(x.size)
out["z"] = corrected / out["standard_error"]
return out- Repository
- Not published yet
- Needs
- Python 3.10 and NumPy
- Tests
- 7, run with
python3 -m unittest -v
Practice
Call Kurtosis().kurtosis on the five values above and confirm -1.3. Then draw 10 000 values from a normal, a uniform and a Laplace distribution with NumPy and run classify and describe on each. Add one value of 50 to the normal sample and see how far the excess kurtosis moves.
Check on learning
- Adding a single extreme value to 1000 normal values barely changes the variance but changes the kurtosis a great deal. Why?
A way to think about it
Compare what one deviation of size 10 contributes to a sum of squares and to a sum of fourth powers.
- A fair coin coded as 0 and 1 has an excess kurtosis of -2, the lowest possible. What about this distribution makes its tails as light as they can be?
A way to think about it
Every value sits exactly one standard deviation from the mean. Ask whether any value is extreme relative to the spread.
- Daily returns of a stock show an excess kurtosis of 8. If you modelled them as normal, which risks would you understate?
A way to think about it
Under a normal model a move of five standard deviations almost never happens. Heavy tails say such moves are far more common.
- With 20 observations is 0.9 and its standard error about 0.99. What can you conclude about the tails?
A way to think about it
Compute the z score. Then think about how wide the range of plausible values is with so few points.
- Why is it wrong to read high kurtosis as a sharp peak, even though many peaked distributions do have high kurtosis?
A way to think about it
Values near the mean contribute almost nothing to . The number is set by the tails, and the peak is a side effect of fixing the variance.