The Chi-Square Distribution
Explore the chi-square distribution, its relationship to the normal distribution, and applications in hypothesis testing
The Chi-Square Distribution
The chi-square distribution (, pronounced "kai-square") is one of the most important distributions in statistics. It arises naturally when working with sample variances and is fundamental to many hypothesis tests.
Definition
If are independent standard normal random variables, then the sum of their squares follows a chi-square distribution with k degrees of freedom:
The PDF of a chi-square random variable with k degrees of freedom is:
Shape and Degrees of Freedom
Degrees of freedom: df =
Chi-Square PDF
Key properties of the chi-square distribution:
- Always positive (sum of squares)
- Right-skewed, especially for small df
- As df increases, the distribution becomes more symmetric (approaches normal)
- The shape depends entirely on the degrees of freedom
Mean, Variance, and Mode
| Property | Formula | Value |
|---|---|---|
| Mean | ||
| Variance | ||
| Standard Deviation | ||
| Mode |
Notice that the mean equals the degrees of freedom (the Mean marker on the plot above), and that it sits to the right of the peak at the mode: the long right tail pulls the mean past the most likely value. This simple relationship makes the chi-square distribution easy to work with.
Critical Values and Hypothesis Testing
In hypothesis testing, we compare a test statistic to a critical value from the chi-square table.
Significance level: =
At df =
- Critical value: =
11.0705
Current value:
Result: =
We fail to reject the null hypothesis at the
P-Value
The p-value is the probability of observing a value as extreme or more extreme than our observed value:
On the plot above, the p-value is the area of the tail shaded from your statistic to the right, and is the area of the red rejection region beyond the critical value. The statistic lands in the rejection region exactly when its tail is the smaller of the two.
The p-value (
Applications
The distribution powers three major hypothesis tests. In a goodness of fit test, you compare observed category frequencies to expected ones:
where is the observed count and is the expected count, with df = k - 1. In a test of independence between two categorical variables, the same formula applies across a contingency table, with df = (r - 1)(c - 1). And to test hypotheses about a population variance given a sample variance , you compute .
All three tests share the same logic: compute a statistic and compare it to the critical value. Try adjusting the significance level =
Exploring the Shape
The distribution connects to the normal, t, F, Gamma, and Exponential distributions. When df = 1, it is simply a squared standard normal. When df = 2, it reduces to an Exponential(1/2). As df grows large, the distribution approaches a normal with mean and variance .
With
Chi-Square PDF
Try it in Code
from scipy import stats
# Chi-square distribution: PDF, CDF, and critical value
df = 5
x = 8
alpha = 0.05
rv = stats.chi2(df)
print(f"f({x}) = {rv.pdf(x):.6f}")
print(f"P(X <= {x}) = {rv.cdf(x):.6f}")
print(f"P(X > {x}) = {rv.sf(x):.6f}")
print(f"Critical value at alpha={alpha}: {rv.ppf(1 - alpha):.4f}")
print(f"Mean = {df}, Variance = {2 * df}")What to explore next
The Binomial Distribution
Explore probability of successes in repeated independent trials
Bivariate Normal Distribution
Explore the 2D Gaussian distribution with correlation
Understanding the Central Limit Theorem
Explore how sample means distribute normally regardless of population distribution
Comparing Distributions with Box Plots
Learn to compare and interpret distributions using interactive box plots
You might also like
The t-Distribution
ExplorationExplore the Student's t-distribution and understand when to use it instead of the normal distribution
Distribution Visualizer
ExplorationVisualize and compare properties of Normal, Binomial, Poisson, Uniform, and Exponential distributions
Normal Distribution Properties
ExplorationExplore the properties of the normal distribution including shape parameters, the empirical rule, z-scores, and probability calculations
The Binomial Distribution
ExplorationExplore probability of successes in repeated independent trials