Chi-Square Test Formula

Chi-square test is a hypothesis test that compares observed frequencies to expected frequencies using the chi-square statistic to assess independence or goodness of fit.

The Formula

χ2=∑(Observed−Expected)2Expected

When to use: You expect a die to land on each face about 16 of the time. You roll it 600 times and compare what you observed to what you expected. If the differences are small, the die is probably fair. If they're large, something is off. The chi-square statistic measures 'how far off are the observed counts from what we expected?'

Quick Example

Roll a die 60 times. Expected: 10 per face. Observed: 8, 12, 11, 7, 13, 9. χ2=(8−10)210+(12−10)210+⋯+(9−10)210=2.8 Compare to χ2 critical value with df=5. Not significant—die appears fair.

Notation

χ2 is the test statistic. Degrees of freedom: goodness-of-fit df=k−1; independence/homogeneity df=(r−1)(c−1).

What This Formula Means

A hypothesis test that compares observed frequencies to expected frequencies using the chi-square statistic to assess independence or goodness of fit.

You expect a die to land on each face about 16 of the time. You roll it 600 times and compare what you observed to what you expected. If the differences are small, the die is probably fair. If they're large, something is off. The chi-square statistic measures 'how far off are the observed counts from what we expected?'

Formal View

χ2=∑i=1k(Oi−Ei)2Ei where Oi is observed count and Ei is expected count; df=k−1 (GOF) or (r−1)(c−1) (independence)

Worked Examples

Example 1

medium
A die is rolled 60 times. Observed: 1→8, 2→12, 3→9, 4→11, 5→13, 6→7. Conduct a chi-square goodness-of-fit test at α=0.05.

Answer

χ2=2.8<11.07. Fail to reject H0. No evidence the die is unfair.

First step

1
Expected under H0 (fair die): E=60/6=10 for each outcome

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Unlock answer keys One Family plan — every worked solution, all subjects

Example 2

hard
A 2×2 table: Men: 30 prefer A, 20 prefer B. Women: 15 prefer A, 35 prefer B. Test independence of gender and preference at α=0.05.

Example 3

medium
Observed counts: 40,30,30. Expected: 33.3,33.3,33.3. Compute χ2.

Common Mistakes

  • Dividing by Observed instead of Expected - the formula is (O−E)2E, scaling each gap by the expected count.
  • Using percentages or means as the data - chi-square requires raw category counts, not proportions or averages.
  • Using the wrong degrees of freedom - goodness-of-fit uses df=k−1; a two-way independence test uses df=(r−1)(c−1).

Why This Formula Matters

It's the standard test for categorical data — the place a mean-based t-test simply doesn't apply because there's nothing to average. Knowing that big squared deviations relative to expected counts drive a large χ2 is what connects 'the counts look off' to a real, p-value-backed conclusion about fairness or association. Recognizing it by "Are the data counts of cases falling into categories, being compared to expected counts (rather than means or continuous values)?" — rather than by familiar numbers — is what lets a student tell it apart from two-sample t-test and two-proportion z-test and correlation / lsrl in a mixed problem set.

Frequently Asked Questions

What is the Chi-Square Test formula?

A hypothesis test that compares observed frequencies to expected frequencies using the chi-square statistic to assess independence or goodness of fit.

How do you use the Chi-Square Test formula?

You expect a die to land on each face about 16 of the time. You roll it 600 times and compare what you observed to what you expected. If the differences are small, the die is probably fair. If they're large, something is off. The chi-square statistic measures 'how far off are the observed counts from what we expected?'

What do the symbols mean in the Chi-Square Test formula?

χ2 is the test statistic. Degrees of freedom: goodness-of-fit df=k−1; independence/homogeneity df=(r−1)(c−1).

Why is the Chi-Square Test formula important in Math?

It's the standard test for categorical data — the place a mean-based t-test simply doesn't apply because there's nothing to average. Knowing that big squared deviations relative to expected counts drive a large χ2 is what connects 'the counts look off' to a real, p-value-backed conclusion about fairness or association. Recognizing it by "Are the data counts of cases falling into categories, being compared to expected counts (rather than means or continuous values)?" — rather than by familiar numbers — is what lets a student tell it apart from two-sample t-test and two-proportion z-test and correlation / lsrl in a mixed problem set.

What do students get wrong about Chi-Square Test?

The procedure for chi-square test is the easy part; the trap is dividing by Observed instead of Expected. Asking "Are the data counts of cases falling into categories, being compared to expected counts (rather than means or continuous values)?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

What should I learn before the Chi-Square Test formula?

Before studying the Chi-Square Test formula, you should understand: hypothesis testing, p value, probability.