Perform chi-square tests of independence and goodness of fit for categorical data analysis
Select a test type and enter data to see results
The chi-square (χ²) test is a statistical method used to analyze categorical data. It tests whether observed frequencies differ significantly from expected frequencies.
Where: O = Observed frequency, E = Expected frequency
Tests whether two categorical variables are independent or associated.
Hypotheses:
Expected Frequency Formula:
Degrees of Freedom:
Tests whether observed sample distribution matches an expected theoretical distribution.
Hypotheses:
Degrees of Freedom:
Where k = number of categories
| Field | Application |
|---|---|
| Medicine | Test relationship between treatment and outcome |
| Marketing | Analyze customer preferences across demographics |
| Genetics | Test if observed ratios match Mendelian predictions |
| Education | Examine relationship between teaching method and performance |
| Social Sciences | Study associations between social factors |
| Quality Control | Test if defect rates match expected distributions |
Scenario: Testing if gender is independent of product preference
| Product A | Product B | Total | |
|---|---|---|---|
| Male | 30 | 20 | 50 |
| Female | 15 | 35 | 50 |
| Total | 45 | 55 | 100 |
Expected frequency for Male/Product A: (50 × 45) / 100 = 22.5
If χ² is large and p-value < 0.05, we conclude gender and product preference are associated.
Measures strength of association (ranges from 0 to 1):
Every coffee helps keep the servers running. Every book sale funds the next tool I'm dreaming up. You're not just supporting a site — you're helping me build what developers actually need.
Use goodness‑of‑fit to test if observed counts match expected proportions; use test of independence to check association between two categorical variables.
Data are counts in categories, observations are independent, and expected cell counts are not too small (rule of thumb ≥ 5 for most cells).
For independence, expected = (row total × column total) ÷ grand total. For goodness‑of‑fit, expected = total × hypothesized proportion.
Larger χ² suggests bigger deviation from expectation. The p‑value quantifies how unusual the observed deviations are under the null hypothesis.