Chi-Square Calculator
Test observed counts against expected ones, or check whether two categorical variables are related, with expected counts shown cell by cell.
Chi-square formula
χ² = Σ (O − E)² ÷ E
Each cell compares what you observed with what the null hypothesis predicts. Squaring and dividing by E makes a difference of 10 matter more in a cell expecting 20 than in one expecting 2,000. The total is compared with a chi-square distribution with the appropriate degrees of freedom to get the p-value; you can also convert any χ² value with the p-value calculator.
Frequently asked questions
What is the difference between goodness of fit and a test of independence?
Goodness of fit compares one categorical variable’s counts with a set of expected proportions, such as checking whether a die is fair. A test of independence uses a two-way table to check whether two categorical variables are associated, such as whether preferred study method differs by year group.
How are expected counts calculated?
For independence: expected = row total × column total ÷ grand total. For goodness of fit: expected = total count × the hypothesised proportion for that category.
What if some expected counts are below 5?
The chi-square approximation becomes unreliable. The usual rule (from W. G. Cochran) is that no expected count should be below 1 and no more than 20% below 5. Combine sparse categories, collect more data, or use Fisher’s exact test for 2×2 tables.
Can I enter percentages instead of counts?
Observed values must be raw counts, never percentages, because the test depends on sample size. Expected values for goodness of fit can be proportions or counts; they are rescaled to the observed total.
What is Cramér’s V?
An effect size for a test of independence, from 0 (no association) to 1 (perfect association). A significant χ² in a huge sample can have a tiny V, meaning the association is real but weak.