Chi-Square Calculator
Run a chi-square test of independence on a contingency table, or a goodness-of-fit test against equal or custom expected proportions. The calculator returns χ², degrees of freedom, the p-value, the expected counts and each cell's contribution, with every step shown.
One row per line; separate the columns with spaces, commas or tabs. You can paste straight from a spreadsheet.
One count per category.
Same order as the observed counts. Any scale works (0.25, 25%, a 9:3:3:1 ratio or counts): values are scaled to the observed total.
How to use the Chi-Square Calculator
- Choose the test: independence (a table of counts for two categorical variables) or goodness of fit (one row of counts).
- Enter the counts. For a table, put each row on its own line; for goodness of fit, list one count per category.
- For goodness of fit, set the expected distribution: equal, or custom proportions such as 9:3:3:1.
- Pick α and read χ², df and the p-value.
- Check the expected counts table and the cell contributions to see where the difference comes from.
Chi-square formulas
| Quantity | Goodness of fit | Test of independence |
|---|---|---|
| Expected count | Ei = n × pi | Eij = (row totali × column totalj) ÷ n |
| Statistic | χ² = Σ (Oi − Ei)² ÷ Ei | χ² = Σ (Oij − Eij)² ÷ Eij |
| Degrees of freedom | k − 1 | (r − 1)(c − 1) |
| Null hypothesis | Data follow the expected proportions | The two variables are independent |
The p-value is the right-tail area of the chi-square distribution beyond your χ². Large χ² values mean the observed counts are far from the expected ones.
Chi-square critical values
| df | α = 0.10 | α = 0.05 | α = 0.01 | α = 0.001 |
|---|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 | 10.828 |
| 2 | 4.605 | 5.991 | 9.210 | 13.816 |
| 3 | 6.251 | 7.815 | 11.345 | 16.266 |
| 4 | 7.779 | 9.488 | 13.277 | 18.467 |
| 5 | 9.236 | 11.070 | 15.086 | 20.515 |
| 6 | 10.645 | 12.592 | 16.812 | 22.458 |
| 8 | 13.362 | 15.507 | 20.090 | 26.124 |
| 10 | 15.987 | 18.307 | 23.209 | 29.588 |
Frequently asked questions
What does a chi-square test tell you?
It tests whether observed counts differ from the counts you would expect under a null hypothesis. The goodness-of-fit test compares one categorical variable with an expected distribution; the test of independence checks whether two categorical variables in a contingency table are related.
How do you calculate the chi-square statistic?
For each category or cell compute (O − E)² ÷ E, where O is the observed count and E the expected count, then add them all up. In a contingency table, E = row total × column total ÷ grand total.
How many degrees of freedom does a chi-square test have?
For goodness of fit, df = number of categories − 1 (minus one more for each parameter estimated from the data). For a test of independence, df = (rows − 1) × (columns − 1). A 2×2 table has 1 degree of freedom.
What if some expected counts are less than 5?
The chi-square test is an approximation that works well when expected counts are at least 5. If many are smaller, merge sparse categories, collect more data, or use an exact test such as Fisher's exact test for 2×2 tables.
Can I use percentages instead of counts?
Observed values must be actual counts (frequencies), not percentages, because the test depends on the sample size. Expected values for goodness of fit can be proportions, percentages or ratios; this calculator scales them to the observed total.
What is Cramér's V?
Cramér's V = √(χ² ÷ (n × (min(r, c) − 1))) measures the strength of association in a contingency table on a 0 to 1 scale. Roughly, below 0.1 is negligible, 0.1–0.3 weak, 0.3–0.5 moderate and above 0.5 strong.
When should I use the Yates correction?
Yates' continuity correction subtracts 0.5 from each |O − E| in a 2×2 table to make the test more conservative when counts are small. Many statisticians consider it overly conservative and prefer Fisher's exact test instead, so it is off by default.