Chi-Square Statistic

A measure of how much observed data deviates from expected frequencies, used to test whether categorical distributions match a hypothesis.

χ2=(OE)2E\chi^2 = \sum \frac{(O - E)^2}{E}

Solve a problem with Chi-Square Statistic

Type the problem. The solver will use Chi-Square Statistic where Chi-Square Statistic is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Chi-Square Statistic takes
χ\chi
OO
EE
Chi-Square Statistic
SymbolMeaning
χ\chiThe Greek letter chi, representing the test statistic itself; the final numerical result you calculate and compare to a critical value to decide whether to reject your hypothesis.
OOThe observed frequency, the actual count of observations in each category of your collected data; must be a non-negative integer from your sample.
EEThe expected frequency, the count you would predict in each category if the null hypothesis were true; calculated from the hypothesized probability distribution.

When to use it

When you want to test whether your observed categorical data matches an expected distribution or whether two categorical variables are independent.

Level

Usually taught in: Statistics · Appears on: AP Statistics

Worked examples

1. Testing fairness of a six-sided die

Problem

A student rolls a fair six-sided die 60 times to test if it is truly fair. The results are: 1 appears 8 times, 2 appears 12 times, 3 appears 9 times, 4 appears 11 times, 5 appears 10 times, and 6 appears 10 times. Calculate the chi-square statistic.
  1. E=606=10E = \frac{60}{6} = 10

    Under the null hypothesis of a fair die, each face should appear equally often, so we divide the total rolls by the number of faces.

  2. χ2=(810)210+(1210)210+(910)210+(1110)210+(1010)210+(1010)210\chi^2 = \frac{(8-10)^2}{10} + \frac{(12-10)^2}{10} + \frac{(9-10)^2}{10} + \frac{(11-10)^2}{10} + \frac{(10-10)^2}{10} + \frac{(10-10)^2}{10}

    We apply the chi-square formula to each category: subtract expected from observed, square it, then divide by expected.

  3. χ2=410+410+110+110+010+010\chi^2 = \frac{4}{10} + \frac{4}{10} + \frac{1}{10} + \frac{1}{10} + \frac{0}{10} + \frac{0}{10}

    We calculate each term: (2)2=4(-2)^2 = 4, (2)2=4(2)^2 = 4, (1)2=1(-1)^2 = 1, (1)2=1(1)^2 = 1, and (0)2=0(0)^2 = 0 for both remaining faces.

  4. χ2=1\chi^2 = 1

    Adding all terms gives 4+4+1+110=1010=1\frac{4+4+1+1}{10} = \frac{10}{10} = 1.

Answer: χ2=1\chi^2 = 1

This low chi-square value suggests the observed frequencies are very close to what we would expect from a fair die, so we would not reject the hypothesis that the die is fair.

2. Testing independence between gender and pet preference

Problem

A researcher surveys 100 students about their gender (male/female) and pet preference (cat/dog). The results are: 20 males prefer cats, 10 males prefer dogs, 30 females prefer cats, and 40 females prefer dogs. Calculate the chi-square test statistic.
  1. Row totals: 20+10=30 males,30+40=70 females\text{Row totals: } 20+10=30 \text{ males}, \quad 30+40=70 \text{ females}

    Sum across each row to find how many students are in each gender group.

  2. Column totals: 20+30=50 cats,10+40=50 dogs\text{Column totals: } 20+30=50 \text{ cats}, \quad 10+40=50 \text{ dogs}

    Sum down each column to find how many students prefer each pet.

  3. Emale, cat=30×50100=15,Emale, dog=30×50100=15E_{\text{male, cat}} = \frac{30 \times 50}{100} = 15, \quad E_{\text{male, dog}} = \frac{30 \times 50}{100} = 15

    For each cell, expected frequency equals row total×column totalgrand total\frac{\text{row total} \times \text{column total}}{\text{grand total}}.

  4. Efemale, cat=70×50100=35,Efemale, dog=70×50100=35E_{\text{female, cat}} = \frac{70 \times 50}{100} = 35, \quad E_{\text{female, dog}} = \frac{70 \times 50}{100} = 35

    We continue calculating expected frequencies for the remaining cells using the same formula.

  5. χ2=(2015)215+(1015)215+(3035)235+(4035)235\chi^2 = \frac{(20-15)^2}{15} + \frac{(10-15)^2}{15} + \frac{(30-35)^2}{35} + \frac{(40-35)^2}{35}

    We apply the chi-square formula to all four cells, using the observed and expected frequencies we calculated.

  6. χ2=2515+2515+2535+2535=5015+5035\chi^2 = \frac{25}{15} + \frac{25}{15} + \frac{25}{35} + \frac{25}{35} = \frac{50}{15} + \frac{50}{35}

    We simplify: (2015)2=25(20-15)^2 = 25, (1015)2=25(10-15)^2 = 25, (3035)2=25(30-35)^2 = 25, (4035)2=25(40-35)^2 = 25.

  7. χ2=103+107=7021+3021=100214.76\chi^2 = \frac{10}{3} + \frac{10}{7} = \frac{70}{21} + \frac{30}{21} = \frac{100}{21} \approx 4.76

    Converting to a common denominator of 21: 5015=103\frac{50}{15} = \frac{10}{3} and 5035=107\frac{50}{35} = \frac{10}{7}, so the sum is approximately 4.76.

Answer: χ2=100214.76\chi^2 = \frac{100}{21} \approx 4.76

This moderate chi-square value suggests some association between gender and pet preference. Whether this is statistically significant would depend on comparing to the critical value for the appropriate degrees of freedom.

3. Comparing bacterial growth rates to a theoretical distribution

Problem

A microbiologist grows 80 bacterial cultures in a new growth medium and categorizes the colony counts as Low, Medium, or High. Based on past data, she expects a 1:2:2 ratio (16 low, 32 medium, 32 high). She observes: 12 low, 38 medium, and 30 high. Calculate the chi-square statistic.
  1. Expected frequencies: E1=16,E2=32,E3=32\text{Expected frequencies: } E_1 = 16, \quad E_2 = 32, \quad E_3 = 32

    From past data, we know the theoretical 1:2:2 ratio, which divides 80 cultures as: Low = 16, Medium = 32, High = 32.

  2. χ2=(1216)216+(3832)232+(3032)232\chi^2 = \frac{(12-16)^2}{16} + \frac{(38-32)^2}{32} + \frac{(30-32)^2}{32}

    We apply the chi-square formula to each growth category, subtracting expected from observed and squaring.

  3. χ2=1616+3632+432\chi^2 = \frac{16}{16} + \frac{36}{32} + \frac{4}{32}

    We compute the numerators: (1216)2=16(12-16)^2 = 16, (3832)2=36(38-32)^2 = 36, (3032)2=4(30-32)^2 = 4.

  4. χ2=1+3632+432=1+4032\chi^2 = 1 + \frac{36}{32} + \frac{4}{32} = 1 + \frac{40}{32}

    We simplify: 1616=1\frac{16}{16} = 1 and 36+432=4032\frac{36+4}{32} = \frac{40}{32}.

  5. χ2=3232+4032=7232=94=2.25\chi^2 = \frac{32}{32} + \frac{40}{32} = \frac{72}{32} = \frac{9}{4} = 2.25

    Combining over a common denominator: 1=32321 = \frac{32}{32}, so 32+4032=7232\frac{32+40}{32} = \frac{72}{32}, which reduces to 94\frac{9}{4} or 2.25.

Answer: χ2=2.25\chi^2 = 2.25

This chi-square value of 2.25 is moderate; it indicates the observed growth distribution deviates somewhat from the expected 1:2:2 ratio, but the degree of deviation must be compared to the critical value to determine if it is statistically significant.

Common mistakes

Where Chi-Square Statistic usually goes wrong
Answer came out wrong
Writing χ2=(OE)/E\chi^2 = \sum (O-E)/E instead of χ2=(OE)2/E\chi^2 = \sum (O-E)^2/E
Always square (OE)(O-E) before dividing by EE; the square ensures all deviations contribute positively to the test statistic.
Using the observed frequency in the denominator: χ2=(OE)2/O\chi^2 = \sum (O-E)^2/O
The denominator must always be EE (expected), not OO (observed); double-check your formula before computing.
Forgetting to calculate expected frequencies in a test of independence and instead using the raw data totals.
For tests of independence, always compute the expected frequency for every cell using the formula above; these are not the same as row or column totals.
The mistakeWhy it is wrongThe fix
Writing χ2=(OE)/E\chi^2 = \sum (O-E)/E instead of χ2=(OE)2/E\chi^2 = \sum (O-E)^2/EForgetting to square the difference means negative and positive deviations cancel out, giving a misleading result.Always square (OE)(O-E) before dividing by EE; the square ensures all deviations contribute positively to the test statistic.
Using the observed frequency in the denominator: χ2=(OE)2/O\chi^2 = \sum (O-E)^2/OMisreading the formula or using the first number available instead of carefully identifying which is the expected frequency.The denominator must always be EE (expected), not OO (observed); double-check your formula before computing.
Forgetting to calculate expected frequencies in a test of independence and instead using the raw data totals.Expected frequencies in a test of independence must be calculated using (row total×column total)/grand total(\text{row total} \times \text{column total})/\text{grand total} for each cell, not just summed marginals.For tests of independence, always compute the expected frequency for every cell using the formula above; these are not the same as row or column totals.

Tips and when to use something else

  • If any expected frequency is less than 5, combine categories or use Fisher's exact test instead, because chi-square is not reliable with very small expected counts.
  • Chi-square only works for categorical (counts) data; for continuous data like measurements or times, use different tests like tt-tests or ANOVA.
  • A chi-square value is always non-negative: it can be zero (if observed perfectly matches expected) but never negative.
  • Use goodness-of-fit when testing whether one categorical variable fits a theoretical distribution; use test of independence when testing whether two categorical variables are related—they use the same formula but different hypothesis setups.

Frequently asked questions

What is the difference between chi-square goodness-of-fit and chi-square test of independence?
Goodness-of-fit tests whether a single categorical variable follows an expected distribution (e.g., does a die roll match fairness?); test of independence tests whether two categorical variables are related or independent (e.g., is pet preference independent of gender?). Both use the same formula, but expected values are calculated differently: goodness-of-fit uses hypothesized probabilities, while independence uses row and column totals.
Why do we square the differences in the chi-square formula?
Squaring (OE)(O-E) accomplishes two things: it makes all differences positive (so deviations in both directions contribute equally) and it gives more weight to larger deviations, which is important for detecting when observed data significantly differs from expected.
What does a large chi-square value tell you?
A large chi-square value means the observed data deviates substantially from what you would expect under the null hypothesis. Whether it is large enough to reject your hypothesis depends on the critical value, which comes from the chi-square distribution with the appropriate degrees of freedom.
Can the chi-square statistic be negative or zero?
No, chi-square is always non-negative; it equals zero only when observed frequencies perfectly match expected frequencies in every category, which is rare in real-world data.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18