Ad Space — Top Banner

Chi-Squared Test Formula

Test whether observed data matches expected frequencies.
The standard test for categorical data independence.

The Formula

χ² = Σ [(O - E)² / E]

The chi-squared test compares observed frequencies to expected frequencies. A large χ² value means the observed data is significantly different from what was expected.

Variables

SymbolMeaning
χ²Chi-squared test statistic
OObserved frequency (actual count)
EExpected frequency (what you would expect by chance)
ΣSum across all categories

Example 1

A die is rolled 60 times. Expected: 10 per face. Observed: 8, 12, 10, 11, 7, 12.

χ² = (8-10)²/10 + (12-10)²/10 + (10-10)²/10 + (11-10)²/10 + (7-10)²/10 + (12-10)²/10

χ² = 0.4 + 0.4 + 0 + 0.1 + 0.9 + 0.4

χ² = 2.2 (with 5 degrees of freedom, p > 0.05 — the die appears fair)

Example 2

Survey: 200 people chose colors. Expected 50 each. Observed: Red=70, Blue=55, Green=40, Yellow=35

χ² = (70-50)²/50 + (55-50)²/50 + (40-50)²/50 + (35-50)²/50

χ² = 8.0 + 0.5 + 2.0 + 4.5

χ² = 15.0 (with 3 df, p < 0.01 — strong evidence of preference)

When to Use It

Use the chi-squared test when:

  • Testing if a die, coin, or random process is fair
  • Determining if two categorical variables are independent
  • Comparing survey responses across different groups
  • Checking if observed genetic ratios match expected Mendelian ratios

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.