Chi-Square Test Calculator Formula
Understand the math behind the chi-square test calculator. Each variable explained with a worked example.
Formulas Used
Chi-Square Statistic
chi_sq = c1 + c2 + c3 + c4Degrees of Freedom (k-1)
df = 3Total Observed
total_observed = o1 + o2 + o3 + o4Total Expected
total_expected = e1 + e2 + e3 + e4Variables
| Variable | Description | Default |
|---|---|---|
o1 | Observed 1 | 45 |
e1 | Expected 1 | 40 |
o2 | Observed 2 | 35 |
e2 | Expected 2 | 40 |
o3 | Observed 3 | 25 |
e3 | Expected 3 | 30 |
o4 | Observed 4 | 45 |
e4 | Expected 4 | 40 |
c1 | Derived value= pow(o1 - e1, 2) / e1 | calculated |
c2 | Derived value= pow(o2 - e2, 2) / e2 | calculated |
c3 | Derived value= pow(o3 - e3, 2) / e3 | calculated |
c4 | Derived value= pow(o4 - e4, 2) / e4 | calculated |
How It Works
How to Perform a Chi-Square Test
Formula
chi-square = Sum of [(Oi - Ei)^2 / Ei]
Compare the computed chi-square statistic to the chi-square distribution with k-1 degrees of freedom (where k is the number of categories). If the statistic exceeds the critical value, reject the null hypothesis that the observed distribution matches the expected distribution.
Worked Example
Four categories: observed 45, 35, 25, 45; expected 40, 40, 30, 40.
o1 = 45e1 = 40o2 = 35e2 = 40o3 = 25e3 = 30o4 = 45e4 = 40
- 01c1 = (45-40)^2/40 = 25/40 = 0.625
- 02c2 = (35-40)^2/40 = 25/40 = 0.625
- 03c3 = (25-30)^2/30 = 25/30 = 0.8333
- 04c4 = (45-40)^2/40 = 25/40 = 0.625
- 05Chi-square = 0.625 + 0.625 + 0.8333 + 0.625 = 2.7083
- 06df = 4 - 1 = 3
- 07Critical value at alpha=0.05, df=3 is 7.815
- 08Since 2.7083 < 7.815, do not reject H0
Ready to run the numbers?
Open Chi-Square Test Calculator