Chi-squared distribution
The sum of k squared standard normals. It is the distribution of sample variances and of many test statistics, and it is skewed to the right.
01The formula
- independent standard normal draws
- degrees of freedom: how many squared normals are added
- their sum, the chi-squared variable
- the density of Q at x
- the gamma function
02See it move
03Where it is used
- Risk managerTests whether realised variance is consistent with the volatility a model assumed.
- Quant researcherRuns goodness-of-fit and independence tests, such as whether returns are spread across buckets as a model predicts.
- Options deskJudges how noisy a realised volatility estimate from k days of data is.
04Why traders use it
Whenever you square and add standardised errors, this is the yardstick. It tells you whether a total of squared surprises is too big to be chance.
05Worked example
A statistic with 5 degrees of freedom comes out at 12.0. The chance of a value that large by chance is 3.48%. The 5% critical value is 11.07; the distribution has mean 5 and standard deviation 3.16.
06How it is built
- Each has mean 1 (the variance of ) and variance 2.
- Adding independent ones gives mean and variance .
- One squared normal has density ; adding of them gives the gamma-shaped density above.
- For a sample of normal values, , which is how it tests variances.
07The common mistake
Using it on data that are not normal. Fat-tailed returns make squared values much more variable, so chi-squared tests of variance reject far too often.
08In Python and LaTeX
from scipy.stats import chi2 k, x = 5, 12 print(round(chi2.sf(x, k), 4), round(chi2.isf(0.05, k), 3))
Q = \sum_{i=1}^{k} Z_i^2 \sim \chi^2_k, \qquad f(x) = \frac{x^{k/2 - 1} e^{-x/2}}{2^{k/2}\,\Gamma(k/2)}, \qquad E[Q] = k,\ \operatorname{Var}(Q) = 2k09Where it fits
Rather not code the maths yourself? Describe your trading idea and let AI build the bot.
Build a bot with AgenKitThe worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.