Chi-Square Test Calculator

Calculate chi-square statistic for goodness-of-fit and test of independence. Determine if observed frequencies significantly differ from expected, or if two categorical variables are associated.

📊 Statistics📐 χ² = Σ (O - E)² / E🔢 Math
Test type
Observed count 1
Expected count 1
Observed count 2
Expected count 2
Observed count 3 (optional)
Expected count 3 (optional)
Please enter valid values.

Formula & Reference

VariableSymbolFormulaUnits
Chi-Square Test Calculatorχ² = Σ (O - E)² / Edimensionless

Step-by-Step Examples

Example 1
Die Fairness

Roll a die 60 times. Observed: 12,8,13,10,9,8. Expected: 10 each (fair die).

  • χ² = (12-10)²/10 + (8-10)²/10 + (13-10)²/10 + (10-10)²/10 + (9-10)²/10 + (8-10)²/10
  • = 0.4+0.4+0.9+0+0.1+0.4 = 2.2
  • df = 6-1 = 5, critical χ² = 11.07
  • 2.2 < 11.07: die appears fair
✓ χ² = 2.2, not significant — die is fair
Example 2
Marketing Campaign

Expected: 25 clicked from each of 3 groups (n=75 total). Observed: 30, 20, 10.

  • χ² = (30-25)²/25 + (20-25)²/25 + (10-25)²/25
  • = 1 + 1 + 9 = 11
  • df = 2, critical χ² = 5.991
  • 11 > 5.991: significant difference between groups
✓ χ² = 11, significant at α=0.05
Example 3
Goodness of Fit

Expected by genetics: 75 tall, 25 short (3:1 ratio). Observed: 70, 30.

  • χ² = (70-75)²/75 + (30-25)²/25
  • = 0.333 + 1.0 = 1.333
  • df = 1, critical = 3.841
  • 1.333 < 3.841: consistent with 3:1 ratio
✓ χ² = 1.33, consistent with Mendelian 3:1

Real-World Applications

Common Mistakes to Avoid

⚠️
Using chi-square when expected counts are too small

Each expected cell must be ≥5 for valid chi-square test. If not: combine categories, use Fisher's exact test (for 2×2 tables), or collect more data.

⚠️
Wrong degrees of freedom

GOF: df = categories - 1 (minus estimated parameters). Independence: df = (rows-1)(cols-1). Always check df before looking up critical value.

⚠️
Chi-square only tests association, not causation

Significant chi-square means the variables are related — it does not tell you why or in which direction the effect goes.

Frequently Asked Questions

What does the chi-square test do?
Tests if categorical data fits an expected distribution (GOF) or if two categorical variables are independent. It compares OBSERVED frequencies to EXPECTED frequencies.
What is the test of independence?
Tests if two categorical variables are associated. Example: are gender and product preference independent? Based on a contingency table of counts. df = (r-1)(c-1).
What is goodness of fit?
Tests if a single variable's distribution matches a hypothesized distribution. Example: are die rolls uniform? Are genetics data consistent with Mendel's ratios?
What is Fisher's exact test?
Alternative to chi-square for 2×2 tables with small expected counts. Computes exact p-value without approximation. Always valid; chi-square is an approximation that works for large samples.
What is Yates' continuity correction?
A small-sample correction to chi-square for 2×2 tables: χ² = Σ(|O-E|-0.5)²/E. Reduces Type I error for small samples. Some statisticians always apply it for 2×2; others prefer Fisher's exact test.

Related Math Calculators

Formula Explorer connections

Interpretation: This formula summarizes data, models uncertainty or supports inference about a population or random process. Assumption: The sampling design and distribution assumptions must match the data. Independence, sample size, outliers and measurement quality can materially affect interpretation.

Conditional Probability Calculator →Confidence Interval Calculator →Correlation Coefficient Calculator →Math Formula Explorer →