Chi-Square Calculator

Testing Whether Observed Counts Fit Expectations

The chi-square statistic answers a question that comes up constantly with categorical data: do the counts I actually observed look like what I expected, or is the difference too large to attribute to chance? This calculator covers the two most common applications — goodness of fit, checking observed counts against a theoretical distribution, and a 2×2 test of independence, checking whether two categorical variables are related.

The Formula

χ² = Σ (O − E)² ÷ E

O is each observed count and E is the corresponding expected count. Larger deviations between observed and expected produce a larger χ² value and a smaller p-value. For the 2×2 independence test, expected counts are computed from the row and column totals under the assumption that the two variables are unrelated.

Worked Example: Testing Die Fairness

Rolling a die 60 times should produce 10 of each face if it's fair. Suppose the actual counts were 8, 12, 9, 11, 10, 10:

Goodness-of-fit test result
χ²Degrees of freedomp-value
1.0050.9626

A p-value this high (far above the conventional 0.05 threshold) means these counts are entirely consistent with a fair die — there's no statistical evidence of bias.

Chi-Square Critical Values

Critical χ² values at common significance levels
dfα = 0.05α = 0.01
13.8416.635
25.9919.210
37.81511.345
49.48813.277
511.07015.086
1018.30723.209

Where This Matters

  • Market research — testing whether customer preferences differ significantly from an assumed distribution.
  • Genetics — comparing observed inheritance ratios against Mendelian expectations.
  • Survey analysis — testing whether two categorical variables, like region and product preference, are statistically associated.
  • Fairness and randomness testing — verifying dice, cards, or random number generators behave as expected.

How to Use This Calculator

  1. Choose Goodness of Fit Test or Test of Independence (2x2 Table) from the dropdown.
  2. For goodness of fit: enter comma-separated observed and expected values.
  3. For independence: enter the four cell counts of your 2×2 contingency table.
  4. Select Calculate to get the χ² statistic, degrees of freedom, and p-value.

Related Calculations

For comparing means instead of counts, see the T-Test Calculator. To measure the strength of a relationship between two continuous variables, use the Correlation Calculator.