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.

PDF

00.10.2051015202530f(x)mean

CDF

00.250.50.751051015202530F(x)

mean 3 · variance 6 · sd 2.449 · mode 1 · entropy 2.054 nats

Formulas

Parameters
  • , the degrees of freedom
Support
PDF
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

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?

← ErlangNoncentral chi-squared →