Chi-Square Calculator
Enter observed and expected frequencies to calculate the chi-square statistic, degrees of freedom, and p-value — tests whether categorical data fits an expected distribution or whether two variables are independent.
Enter your values above to see the results.
Tips & Notes
- ✓All expected frequencies must be at least 5 for the chi-square approximation to be valid. With smaller expected frequencies, use Fisher's exact test instead.
- ✓Chi-square tests only use counts — never proportions or percentages directly. Convert percentages back to counts using the sample size before running the test.
- ✓Chi-square is always one-tailed (right-tailed). Large χ² values fall in the rejection region. There is no concept of a "left-tailed" chi-square test.
- ✓Chi-square tests association, not causation and not the strength of association. A significant chi-square only tells you the variables are not independent — use Cramér's V to measure how strongly they are related.
- ✓For a 2×2 table with small samples (total n < 20), use Yates' continuity correction or Fisher's exact test. Standard chi-square overestimates significance with small counts.
Common Mistakes
- ✗Using percentages instead of counts. The chi-square formula requires raw counts (observed frequencies), not proportions. Entering 25% instead of the actual count of 25 will give a completely wrong result.
- ✗Having expected frequencies below 5. Chi-square is unreliable when any expected cell frequency is less than 5. Combine low-frequency categories or use Fisher's exact test when this occurs.
- ✗Confusing goodness-of-fit with independence test. Goodness-of-fit tests one variable against a theoretical distribution. Independence test examines whether two categorical variables are related. The setup and degrees of freedom differ.
- ✗Interpreting a significant chi-square as measuring how strong the association is. Chi-square only tests whether an association exists. To measure strength, compute Cramér's V = √(χ²/(n×(min(r,c)−1))).
- ✗Using chi-square for continuous data. Chi-square applies to categorical counts only. If your data is numerical (heights, temperatures, incomes), use t-tests or ANOVA, not chi-square.
Chi-Square Calculator Overview
The chi-square test is the standard tool for categorical data analysis. Unlike t-tests and ANOVA (which compare means of numerical data), chi-square tests whether counts or frequencies match what we would expect. It answers two types of questions: does this sample fit my expected distribution (goodness-of-fit)? And are these two categorical variables related (independence test)?
Chi-square statistic — sum of standardized squared deviations:
χ² = Σ [(O − E)² / E]
EX: A die is rolled 60 times. Expected: 10 per face. Observed: [8,12,9,11,10,10] → χ² = (8−10)²/10 + (12−10)²/10 + ... = 0.4+0.4+0.1+0.1+0+0 = 1.0 → low χ², no evidence the die is unfairDegrees of freedom:
Goodness-of-fit: df = k − 1 | Independence test: df = (rows−1) × (columns−1)
EX: 6-sided die test → df = 6−1 = 5 | 2×3 contingency table → df = (2−1)×(3−1) = 2Expected frequencies for independence test:
E = (Row total × Column total) / Grand total
EX: 200 people, 100 male/100 female, 80 prefer A / 120 prefer B → E(male, A) = (100×80)/200 = 40Chi-square critical values at α = 0.05:
| df | Critical Value (α=0.05) | Critical Value (α=0.01) | Reject H₀ if χ² exceeds |
|---|---|---|---|
| 1 | 3.841 | 6.635 | 3.841 at 5% significance |
| 2 | 5.991 | 9.210 | 5.991 at 5% significance |
| 3 | 7.815 | 11.345 | 7.815 at 5% significance |
| 4 | 9.488 | 13.277 | 9.488 at 5% significance |
| 5 | 11.070 | 15.086 | 11.070 at 5% significance |
Frequently Asked Questions
The chi-square test measures whether observed categorical frequencies match expected frequencies. For goodness-of-fit: does this sample match a theoretical distribution (e.g., is a die fair)? For independence: are two categorical variables related (e.g., is gender related to product preference)? The test produces χ² = Σ(O−E)²/E — larger values mean observed frequencies deviate more from expected, making the null hypothesis less credible.
The p-value is the probability of observing a χ² statistic this large or larger if the null hypothesis is true. p=0.03 means there is a 3% chance of getting this result by random chance when H₀ is true. Conventionally: p < 0.05 → reject H₀ (significant association or poor fit). p ≥ 0.05 → fail to reject H₀ (data consistent with expected distribution or independence). Never say H₀ is proven true when p is large.
All expected cell frequencies should be at least 5 for the chi-square approximation to be reliable. If any expected frequency falls below 5, the chi-square distribution is a poor approximation and p-values will be inaccurate. Solutions: combine adjacent categories to increase expected counts, collect more data, or use Fisher's exact test (for 2×2 tables) which works correctly with small counts.
Goodness-of-fit tests one variable against a theoretical distribution. Example: are the colors of M&Ms distributed as 20% each? You compare observed counts against expected counts based on the claimed proportions. Independence test examines whether two categorical variables are related using a contingency table. Example: is smoking status independent of lung disease diagnosis? Expected frequencies are calculated from the marginal totals.
Nothing directly. Chi-square only tests whether an association exists, not how strong it is. A large sample can make a trivially small association statistically significant. To measure association strength, compute Cramér's V = √(χ²/(n×(min(rows,cols)−1))). V ranges from 0 (no association) to 1 (perfect association). V < 0.1 is negligible, 0.1–0.3 is weak, 0.3–0.5 is moderate, > 0.5 is strong.
No. Chi-square applies only to categorical count data — numbers of occurrences in each category. For numerical data, use t-tests (comparing two means) or ANOVA (comparing three or more means). If you want to test whether numerical data follows a specific distribution (like normality), use the Kolmogorov-Smirnov test or Shapiro-Wilk test instead of chi-square.