The Claude Quant PlaybookDownload ebookDownload ebook

Chi-squared distribution

advancedDistributions11 of 11

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.

Build a trading system with Claude.Download ebook

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

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

  1. Each has mean 1 (the variance of ) and variance 2.
  2. Adding independent ones gives mean and variance .
  3. One squared normal has density ; adding of them gives the gamma-shaped density above.
  4. 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) = 2k

09Where it fits

Rather not code the maths yourself? Describe your trading idea and let AI build the bot.

Build a bot with AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.