Continuous distribution · also called χ²
Chi-squared distribution
The sum of the squares of independent standard normal variables. It is the reference distribution for goodness-of-fit and independence tests, and follows it with degrees of freedom when the data are normal, which gives confidence intervals for a variance.
Chi-squared probability calculator
P(X ≤ 2.4) = 0.506365
At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends.
CDF
mean 3 · variance 6 · sd 2.449 · mode 1 · entropy 2.054 nats
Formulas
| Parameters |
|
|---|---|
| Support | |
| CDF | |
| Mean | |
| Variance | |
| Mode | |
| MGF | |
| Entropy |
Worked example
A die is rolled 60 times and shows the faces 1 to 6 this many times: 5, 8, 9, 8, 10, 20. Is it fair?
Each face should appear 10 times. Pearson's statistic is on degrees of freedom, so the p-value is . Evidence that the die favours six. answer checked by code
How it relates to others
- Special case← Gamma: Gamma() is Chi-squared(). checked by code
- Special case→ Exponential: Chi-squared() is Exponential(). checked by code
- Transformation← Normal: If are independent standard normals, is Chi-squared(). checked by code
- Transformation→ Student's t: If is standard normal and an independent Chi-squared(), is .
- Transformation→ F: If are independent Chi-squared() and Chi-squared(), is F().
- Special case← Wishart: Each diagonal entry of a Wishart() matrix is times a Chi-squared(); with and the Wishart is Chi-squared(). checked by code
- Transformation← Half-normal: If is Half-normal(), is Chi-squared(). checked by code
- Transformation→ Maxwell–Boltzmann: If is Chi-squared(), is Maxwell–Boltzmann(): the length of a vector of three independent Normal() components. checked by code
- Special case← Noncentral chi-squared: Noncentral chi-squared() is Chi-squared(). checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.chi2(df=3)
X.pdf(2) # f(2) = 0.2076
X.cdf(2) # P(X ≤ 2) = 0.4276
X.mean(), X.var() # 3, 6
X.ppf(0.95) # 95th percentile
X.rvs(size=10, random_state=0)
rng = np.random.default_rng(0)
rng.chisquare(df=3, size=10)Choosing between this and its neighbours? Which distribution for measurements and errors?