Moments
The mean and the variance describe where a distribution sits and how widely it spreads. Two more numbers describe its shape. All of them are moments.
The -th moment of is , found by LOTUS (lesson 5.3.1) with . The first moment is the mean . The -th central moment is , and the second is the variance.
Central moments carry units: is in units cubed, so it grows times when dollars become cents. Standardising first removes the units.
Rule: Standardised moments
counts standard deviations from the mean (lesson 5.3.2). Its moments have no units, and they do not change when is shifted or multiplied by a positive number.
The first two are always the same: and . So the new information starts with the third and the fourth.
Try it
std_moment standardises the values, then applies LOTUS to . For the die, to 4 give 0, 1, 0 and 1.7314.
The second line does the same for , with the same results: the shape has not changed.
Skewness: which tail is longer
Cubing keeps the sign of each deviation and magnifies the large ones. If the large deviations lie mostly above the mean, the average cube is positive; if mostly below, negative. That average is the skewness.
Rule: Skewness
Positive: a long tail to the right, made of rare values far above the mean. Negative: a long tail to the left. A symmetric distribution has skewness 0.
Take a Bernoulli variable with : with probability 0.2 and 0 otherwise. Its mean is 0.2 and its standard deviation is (lesson 5.3.2).
| 0 | 1 | |
|---|---|---|
| 0.8 | 0.2 | |
| 2 | ||
| 8 |
So . The rare 1, two standard deviations above the mean, outweighs the common 0 just below it. In general a Bernoulli variable has skewness : 1.5 at , 0 at and at .
Three binomial distributions with 10 trials. A long tail to one side gives skewness of that sign, and pulls the mean towards it, away from the most likely value.
- The mean follows the tail. With the most likely count is 1, but the mean is 1.5. Lesson 5.3.1's wait for a 5 or a 6 is the same: peak at 1, mean 3, skewness 2.0412.
- A mirror flips the sign. has skewness ; shifting or multiplying it by a positive number changes nothing.
- Same mean and spread, different shape. Lesson 4.6.1's three bets all have mean 0 and standard deviation 0.2. Their skewness is 0, 1.5 and , and the negative one, the rare big loss, was the one a concave utility minded most.
Try it
The first line is the Bernoulli table, then its formula. The loop gives the three binomials of the figure.
The last lines are the wait of lesson 5.3.1, summed over 400 terms, and lesson 4.6.1's three bets.
Kurtosis: how heavy the tails are
Fourth powers magnify large deviations even more. A value 3 standard deviations from the mean adds , while one at half a standard deviation adds . So the fourth moment is driven by the rare, large deviations.
Rule: Kurtosis
How much of the spread comes from rare values far from the mean, compared with common values near it. It is never below 1, and it is the same for , and any with .
A family of examples shows it best. Let be 0 with probability , and or with probability each, where . Then the mean is 0 and the variance is for every , so and the kurtosis is .
| the values and their chances | kurtosis | |
|---|---|---|
| 1 | or 1, each | 1 |
| 0 with ; or 1.73, each | 3 | |
| 0.1 | 0 with 0.9; or 3.16, each 0.05 | 10 |
All three have mean 0 and variance 1. With , is usually 0 but now and then jumps 3.16 standard deviations, and the kurtosis is 10 times the coin's.
Three distributions with the same mean and variance. The rarer and further out the jumps, the larger the kurtosis.
Kurtosis is often described as how peaked a distribution is. The case has both a tall spike at 0 and far-out jumps, but it is the jumps that make the number large. Read kurtosis as a measure of the tails.
A fair die has kurtosis 1.7314: it cannot stray far from its mean.
The normal's values, and excess kurtosis
The normal distribution, the bell curve of lesson 2.6.3, has skewness 0 and kurtosis 3 (lesson 5.4.3). Kurtosis is therefore often quoted relative to 3.
Rule: Excess kurtosis
0 for a normal. Positive means heavier tails than a normal, often called fat tails; negative means lighter tails.
| distribution | skewness | excess kurtosis |
|---|---|---|
| the coin | 0 | |
| a fair die | 0 | |
| a normal | 0 | 0 |
| Bernoulli, | 1.5 | 0.25 |
| wait for a 5 or a 6 | 2.0412 | 6.1667 |
| the family with | 0 | 7 |
In the family, matches the normal's kurtosis exactly. Case study 5.3.5 measures the excess kurtosis of daily returns.
Try it
The loop prints the kurtosis of the family for each , then the die's. The middle line draws a million normal values in one seeded run: skewness 0.0016 and kurtosis 2.9989, close to 0 and 3.
norm.stats(moments="mvsk") asks SciPy for the mean, variance, skewness and kurtosis. Its last 0 is the excess kurtosis, and so are the 0.25 and 6.1667 on the last two lines.
Sample skewness and kurtosis
For data , treat each value as equally likely, with probability , and apply the same formulas. That uses the sample mean and the standard deviation that divides by . scipy.stats.skew and scipy.stats.kurtosis do exactly this by default.
Try it
10,000 seeded die rolls. The sample skewness is 0.0154 and the excess kurtosis , close to the die's 0 and .
The last line repeats both by hand with , where rolls.std() divides by . It matches SciPy's default.
A sample kurtosis is noisy
A sample's kurtosis rests on its few most extreme values, so short samples give very different answers. Draw 100 values at a time from the family with , whose kurtosis is 10. Five seeded samples give 12.5, 14.25, 5.79, 8.99 and 9.94.
Only big samples pin it down: 1,000,000 draws give 9.9996. The higher the moment, the more data it needs.
Try it
Each line of the loop is a separate sample of 100 draws. rng.choice draws from the three values with the given chances.
fisher=False asks for the plain kurtosis, so the target is 10.
Where the measures break
- No spread. If every value is the same, and is . SciPy returns
nan, "not a number", with a warning. - An infinite kurtosis. The sum for can diverge even when the variance is finite. The Student distribution with 4 degrees of freedom (lesson 5.4.4) is an example. Its sample kurtosis never settles, however long the sample.
Try it
warnings.catch_warnings hides SciPy's warning for the constant data, so only the two nan values print.
SciPy reports the distribution's variance, 2, and its excess kurtosis, inf.
Common mistakes
- SciPy's kurtosis is excess kurtosis by default. Normal data gives about 0, not 3.
- Positive skewness means a long right tail. Most of the values then sit below the mean, as in the binomial with .
- Standardise before cubing. has units cubed and changes with the units; the skewness does not.
- A sign flip changes the skewness, not the kurtosis. has skewness and the same kurtosis.
- Kurtosis measures the tails, not the peak.
- Do not trust the kurtosis of a short sample. A few extreme values decide it.
Skewness and kurtosis
0 of 11 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- The -th moment is ; standardised moments , with , have no units. The first two are always 0 and 1.
- Skewness : positive for a long right tail, negative for a long left one, 0 when symmetric. The mean moves towards the tail. flips its sign.
- Kurtosis measures how much of the spread comes from rare, large deviations. Excess kurtosis is kurtosis , which is 0 for a normal.
scipy.stats.skewandscipy.stats.kurtosisuse divide-by- moments;kurtosisreports excess kurtosis unlessfisher=False.- Sample kurtosis is noisy. It is undefined with no spread, and can be infinite, as for the Student with 4 degrees of freedom.