Chi-Square Calculator
Goodness of fit · independence · χ² distribution
Result
Enter data and click Calculate
Compute chi-square statistic, p-value, degrees of freedom, and effect size.
Chi-Square Distribution
Python Compiler
What Is a Chi-Square Test?
A chi-square test (χ²) is a statistical hypothesis test used to determine whether there is a significant association between categorical variables or whether observed frequencies differ from expected frequencies. It is one of the most widely used non-parametric tests in statistics.
Categorical Analysis
Analyze relationships between categorical variables such as gender, preference, treatment group, or survey response.
Expected vs Observed
Compare what you observed in your data against what you would expect under the null hypothesis of no association.
Statistical Significance
Determine if the difference between observed and expected frequencies is large enough to reject the null hypothesis.
Chi-Square Formula
E11 = (40 × 50) / 100 = 20, E12 = (40 × 50) / 100 = 20
E21 = (60 × 50) / 100 = 30, E22 = (60 × 50) / 100 = 30
χ² = (30−20)²/20 + (10−20)²/20 + (20−30)²/30 + (40−30)²/30 = 5 + 5 + 3.33 + 3.33 = 16.67
df = (2−1)(2−1) = 1, p-value < 0.001 → Reject H₀
Interpreting Results
❌ Reject H₀
When p-value < α, the observed frequencies differ significantly from expected. There is a statistically significant association between the variables.
✅ Fail to Reject H₀
When p-value ≥ α, there is insufficient evidence to conclude an association. The observed differences could be due to chance.
📏 Effect Size (Cramér’s V)
Measures strength of association: V ≈ 0.1 is small, V ≈ 0.3 is medium, and V ≥ 0.5 indicates a large effect size.
🎯 Practical Significance
A statistically significant result may not be practically meaningful. Always consider effect size, sample size, and real-world context alongside the p-value.
Assumptions & Limitations
- Independence: Observations must be independent of each other. Each subject contributes to only one cell.
- Sample size rule: Expected frequencies should be at least 5 in 80% of cells, and no cell should have an expected frequency below 1.
- Categorical data: Variables must be categorical (nominal or ordinal). Chi-square is not appropriate for continuous data.
- Random sampling: Data should be obtained through random sampling from the population of interest.
Tip: When expected frequencies are too small (especially in 2×2 tables), use Fisher’s exact test instead. For ordinal data with a natural ordering, consider the Cochran-Armitage trend test.
Applications
| Field | Example Use Case |
|---|---|
| Medicine | Test whether treatment outcome is associated with patient group |
| Marketing | Analyze if product preference differs by demographic segment |
| Genetics | Test if observed genotype ratios match Mendelian expected ratios |
| Education | Determine if pass/fail rates differ across teaching methods |
| Quality Control | Check if defect rates are independent of production line |
| Social Sciences | Examine if voting preference is related to age group or region |