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
- 1Choose goodness of fit or test of independence.
- 2Enter observed counts (and expected counts or proportions for goodness of fit), or a table with one row per line.
- 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
- Grade Curve Calculator
Curve a set of test scores — raise the top score to 100, add a flat bonus, or scale to a target average — and see each student's new score.
- P-Value Calculator (z, t, chi-square)
Get the p-value for a z-score, t-statistic or chi-square statistic — one- or two-tailed — and check it against your significance level.
- Test Score & Percentage Grade Calculator
Turn points earned into a percentage and letter grade — and see the grade for every number of wrong answers on a test.
- Exponent, Root & Logarithm Calculator
Calculate powers, square/cube/nth roots (with radical simplification like √72 = 6√2) and logarithms in any base.
- Multiplication Table Generator
Generate a times table for any number or a full multiplication grid up to 20 × 20 — ready to print or copy.
- FAST NUCES Aggregate Calculator
Calculate your FAST-NUCES merit for Computing (CS, AI, SE, Data Science, Cyber Security), Engineering and Business programmes using FAST's official admission-test, HSSC and SSC weightages.