Guide
Chi-square tests: goodness of fit, independence and Fisher’s exact test
Many questions are about counts in categories: is this die fair, do men and women answer a question differently, do offspring appear in the ratio a theory predicts? The chi-square test compares the counts you observed with the counts you would expect if a simple hypothesis were true, and turns the gap into a p-value. This calculator runs the two standard versions, adds the exact test for small 2 × 2 tables and draws the distribution with your result marked.
The statistic
For each category the tool takes the observed count O and the expected count E and adds up (O − E)² / E. A large total means the data are far from what the hypothesis predicts. The p-value is the probability, if the hypothesis were true, of a total at least that large, taken from the chi-square distribution with the right degrees of freedom. It is compared with your significance level α, and the tool reports the critical value at that level.
Goodness of fit
Choose Goodness of fit and enter one row of counts. Expected counts can be All categories equally likely, Given proportions or percentages, or Given expected counts, which must add to the same total. Degrees of freedom are the number of categories minus 1, minus any parameters estimated from the data, which you can set. Observed counts of 5, 8, 9, 8, 10 and 20 for a die give χ² = 13.4, df = 5 and p = 0.0199, so a fair die is rejected at 5%. Most of the gap comes from the 20 sixes, which contribute 10 of the 13.4.
Test of independence
Choose Independence in a table and enter the counts with one row per line. Expected counts are the row total times the column total divided by the grand total. For [[10, 20], [30, 40]] these are 12, 18, 28 and 42, and the result is χ² = 0.79365079, df = 1, p = 0.3730, Cramér’s V 0.089 and a phi coefficient of 0.089: no evidence of a link. A 3 × 3 table of 30 20 10, 20 25 15, 10 15 35 gives χ² = 30, df = 4, p below 0.0001 and V = 0.289.
2 × 2 tables, Yates and Fisher
A 2 × 2 table gets extra rows: the Fisher exact test p-value and the odds ratio. For the default table Fisher’s p is 0.5045 and the odds ratio 0.667. The Yates continuity correction can be switched on for 2 × 2 tables; it reduces χ² to 0.4464286 for the default and is conservative. Use Fisher whenever an expected count is below 5, as in [[3, 1], [1, 3]], where Fisher gives p = 0.4857 while the plain χ² gives 0.1573.
Effect size and contributions
A p-value says whether a pattern is unlikely to be chance, not how strong it is. Cramér’s V, from 0 to 1, measures strength: 0.089 is a tiny association and 0.289 a modest one. Tables show the expected counts and each cell’s contribution to χ², so you can see where the difference lies: in the die example the sixes contribute 10 and the ones 2.5. Contributions of the 3 × 3 table are 5, 0, 5, 0, 1.25, 1.25, 5, 1.25 and 11.25.
Worked examples
Mendel’s peas: counts 315, 101, 108 and 32 against expected proportions 9, 3, 3 and 1 have expected counts 312.75, 104.25, 104.25 and 34.75, so χ² = 0.47002398, df = 3, p = 0.9254: an excellent fit. The critical value at 5% is 7.81473. A fair die, a gene ratio and a survey cross-tabulation are the three typical uses, and each is a sample chip on the page.
Limits
Counts must be actual frequencies from independent observations, not percentages, and each person or item should appear once. The chi-square approximation is unreliable when many expected counts are below 5. A significant result does not show cause, and a non-significant one does not prove the null hypothesis, it only fails to reject it. Tables with a row or column of zeros are rejected because their expected counts are zero.
Related tools
- T-Test Calculator compares means when the data are measurements rather than counts.
- Linear Regression Calculator studies the relation between two measured variables.
- Z-Score Calculator gives normal tail areas, a close relative of the chi-square tail.
- A/B Test Calculator applies a 2 × 2 comparison to conversion rates.
Checked against the current version of the Chi-Square Calculator on .

