The chi-square (χ²) test is the go-to statistical test for categorical data. It answers questions like: "Is this die fair?", "Is there a relationship between gender and voting preference?", "Does the distribution of blood types match genetic predictions?" This guide covers both major types of chi-square tests.

What is the Chi-Square Statistic?

χ² = Σ (O − E)² / E

Where O = observed frequency and E = expected frequency. The larger χ², the greater the discrepancy between what you observed and what you expected under H₀.

Type 1: Goodness of Fit Test

Purpose: Test whether observed frequencies for one categorical variable match a hypothesised distribution.

H₀: The observed frequencies follow the specified distribution.

df = k − 1 (where k = number of categories)

Example: A genetics experiment crosses two plants. Mendel's law predicts offspring ratios of 9:3:3:1 for four phenotypes. You observe 315, 108, 101, 32 offspring. Does this match the 9:3:3:1 prediction?

Expected: 556 total × 9/16 = 312.75, 556 × 3/16 = 104.25, 104.25, 34.75. χ² = 0.47. p = 0.93. Fail to reject H₀ — data matches Mendel's predictions.

Type 2: Test of Independence

Purpose: Test whether two categorical variables are related (independent or associated) using a contingency table.

H₀: The two variables are independent (no association).

df = (rows − 1) × (columns − 1)

Expected frequencies: E = (row total × column total) / grand total

Example: Survey 200 people on preferred exercise type (gym/running/cycling) by gender. Is exercise preference independent of gender?

Assumptions and Conditions

Interpreting the Results

After a significant result, always calculate effect size: Cramér's V = √(χ²/n×(min(r,c)−1)). V = 0.10 small, 0.30 medium, 0.50 large.

Chi-Square vs Fisher's Exact Test

For 2×2 tables with small expected frequencies (any E < 5), use Fisher's Exact Test instead of chi-square. Fisher's test computes an exact p-value without the large-sample approximation that chi-square requires.

Use our free Chi-Square Test Calculator for full results with step-by-step working, or our Fisher's Exact Test Calculator for small samples.