Chi-Square Test Calculator (with Fisher's exact)
Chi-square test of independence or goodness of fit: χ², df, p-value, expected counts, residuals, Cramér's V, and Fisher's exact test for 2 × 2 tables.
p = 2.954e-7 is below α = 0.05: the counts are unlikely under the null hypothesis, which is rejected at this level.
Expected counts
| 703.671 | 319.645 | 533.683 |
| 542.329 | 246.355 | 411.317 |
Pearson residuals (O − E) / √E
| 2.199 | 0.411 | -2.843 |
| -2.505 | -0.469 | 3.239 |
Calculated in the browser: the χ² tail from the regularized incomplete gamma function, Fisher's test from the hypergeometric distribution. The counts are kept in local storage.
How to use
- For independence, paste the table of counts, one row per line; the example button loads R's documented case.
- For goodness of fit, switch modes, enter the observed counts and, if the categories are not equally likely, their expected proportions.
- Read χ², the degrees of freedom and the p-value, then the residuals to see which cells drive the result.
- For a 2 × 2 table, compare the corrected and uncorrected χ² and read Fisher's exact test, especially when counts are small.
- Heed the warning about expected counts below 5: there the p-value from the χ² approximation should not be trusted.
About this tool
ShowHide
Paste a table of counts to test whether two categorical variables are independent, or a row of counts to test whether they fit expected proportions, and get χ², the degrees of freedom, the p-value, the expected count for every cell, the Pearson residuals that show where the departure is, and Cramér's V for its size. The example is the one in R's own documentation, Agresti's party identification by gender, which gives χ² = 30.07 on 2 degrees of freedom and p = 2.954 × 10⁻⁷ here as it does there. A 2 × 2 table gets two extras. Yates's continuity correction is applied by default, as R and scipy apply it, and the uncorrected χ² is shown beside it, because the two can land on opposite sides of 0.05: a table of 12, 5, 3, 9 gives 5.85 uncorrected and 4.17 corrected. And Fisher's exact test is computed from the hypergeometric distribution in all three directions — the right test when counts are small, and the one the chi-square approximation is only standing in for. The tool counts how many expected cells fall below 5, the usual threshold at which the approximation stops being trustworthy, and says so rather than printing a p-value that looks as precise as any other. For goodness of fit, expected proportions can be given as percentages, fractions or any weights, since they are scaled to the observed total, and a field for parameters estimated from the data reduces the degrees of freedom the way fitting a distribution requires. The tail probability comes from the regularized incomplete gamma function, so very small p-values are reported to their true size rather than as zero.
Frequently asked questions
Should I use Yates's correction?
It is the default in R and scipy for 2 × 2 tables, and this tool follows them so the numbers match. The correction makes the test conservative, sometimes markedly so; many statisticians now prefer to report the uncorrected statistic with a large sample and Fisher's exact test with a small one. The tool shows both χ² values so the choice is visible rather than hidden in a default.
When should I use Fisher's exact test instead?
When the table is 2 × 2 and some expected counts are small — the usual rule of thumb is below 5. Fisher's test computes the exact probability of tables at least as extreme as the one observed with the margins fixed, so it does not rely on a large-sample approximation. For large counts it and the chi-square test agree closely.
What do the residuals tell me?
Each Pearson residual is (observed − expected) divided by the square root of the expected count. Their squares add up to χ², so the cells with the largest absolute residuals are the ones responsible for a significant result, and the sign says whether that cell has more or fewer cases than independence would predict. Values beyond about ±2 are worth a look.
What is Cramér's V?
A measure of how strong the association is, from 0 for none to 1 for complete, computed as the square root of χ² divided by n times one less than the smaller dimension of the table. It exists because χ² grows with the sample size: a trivial association in a huge sample can be highly significant, and V shows how small it really is. It is computed from the uncorrected χ², as scipy computes it.
What does the estimated-parameters field do?
In a goodness-of-fit test the degrees of freedom are the number of categories minus one. If the expected proportions were themselves estimated from the same data — fitting a Poisson mean, say — each estimated parameter removes one more degree of freedom. Enter how many were estimated and the degrees of freedom and p-value adjust, as scipy's ddof does.
Related tools
Image Padding & Border
Add solid or transparent padding and an optional border around any image.
Image
Matrix Calculator (exact fractions)
Determinant, inverse, RREF and rank, transpose, product and A x = b for matrices up to 12 × 12, in exact fractions rather than rounded decimals.
Math & Statistics
Linear Regression Calculator
Paste (x, y) pairs and instantly get the best-fit line — slope, intercept, Pearson r, R², and a live prediction — all computed in your browser.
Math & Statistics
Modular Exponentiation Calculator (aᵇ mod m)
Compute a^b mod m exactly for arbitrarily large integers using fast binary exponentiation, plus the modular multiplicative inverse of the base.
Math & Statistics
A/B Test Calculator (significance & sample size)
Compare two conversion rates: p-value, lift, Wilson and Newcombe intervals, a sample-ratio-mismatch check, and the sample size the next test needs.
Math & Statistics
t-Test Calculator (paired, Welch, one-sample)
One-sample, paired and two-sample t-tests from raw data or summary statistics: t, degrees of freedom, p-value, confidence interval and Cohen's d.
Math & Statistics