Account

What new tool do you want?

Math & Education

Chi-Square Test Calculator (Goodness of Fit & Contingency Table)

Run a chi-square goodness-of-fit test or a test of independence on a contingency table: get χ², degrees of freedom, the p-value and whether the result is significant.

How to use

  1. 1Choose goodness of fit or test of independence.
  2. 2Enter observed counts (and expected counts or proportions for goodness of fit), or a table with one row per line.
  3. 3Read χ², degrees of freedom and the p-value.

How it's calculated

χ² = Σ (O − E)² ÷ E. Goodness of fit: df = categories − 1. Independence: E = row total × column total ÷ grand total, df = (rows − 1)(columns − 1). p = P(χ²_df ≥ χ²).

Frequently asked questions

When should expected counts be at least 5?

The chi-square approximation is reliable when every expected count is 5 or more. With smaller counts, consider Fisher's exact test or combining categories.

Can I enter proportions as expected values?

Yes for goodness of fit — enter proportions or percentages and they're scaled to your total observed count. Leave it blank to test equal proportions.

What does a small p-value mean?

That a deviation this large would be unlikely if the null hypothesis were true (the categories fit the expected pattern, or the two variables are independent).

Goodness of fit: does the data match what you expected?

Rolling a die 60 times and getting each face about 10 times fits a fair die; getting 25 sixes doesn't. The goodness-of-fit test adds up (observed − expected)² ÷ expected across categories. In the default example — 50, 30 and 20 against an equal split of 33.3 each — χ² is 14 with 2 degrees of freedom, a p-value under 0.001.

Independence: are two variables related?

A contingency table cross-tabulates two categorical variables, such as treatment versus outcome. Expected counts come from the row and column totals, assuming no relationship. In the 2 × 2 example (20/30 against 30/20) every expected count is 25, χ² is 4 and p ≈ 0.046 — significant at the 5% level, but not at 1%.

Related tools

More: Math & Education