Chi Square Test Calculator
Calculate chi square test instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods.
Reviewed by Daniel Agrici, Founder & Lead Developer
Formula
Chi-Square = Sum[(Observed - Expected)^2 / Expected]
The chi-square statistic sums the squared differences between observed and expected frequencies, each divided by the expected frequency. Degrees of freedom = (rows - 1) x (columns - 1). Compare the statistic to the chi-square distribution to find the p-value.
Worked Examples
Example 1: Gender and Product Preference
Problem:Survey: 50 males prefer Product A, 30 prefer B. 20 females prefer A, 40 prefer B. Is there an association between gender and preference?
Solution:Observed: [[50,30],[20,40]], Grand total = 140\nExpected: [[35,35],[35,35]] (if independent, no difference)\nChi-square = (50-35)^2/35 + (30-35)^2/35 + (20-35)^2/35 + (40-35)^2/35 = 6.43 + 0.71 + 6.43 + 0.71 = 14.29\ndf = 1, p < 0.001
Result:Chi-square = 14.29, df = 1, p < 0.001 — Significant association
Frequently Asked Questions
What is the chi-square test of independence?
The chi-square test of independence determines whether there is a statistically significant association between two categorical variables. It compares observed frequencies (your actual data) to expected frequencies (what you would expect if the variables were independent). A large chi-square statistic indicates that observed frequencies differ substantially from expected frequencies, suggesting the variables are associated.
What are the assumptions of the chi-square test?
Key assumptions: (1) Data are frequencies/counts, not percentages or means. (2) Categories are mutually exclusive — each observation falls in exactly one cell. (3) Observations are independent. (4) Expected frequency in each cell should be at least 5 (Cochran's rule). If expected values are below 5, consider Fisher's exact test or combining categories.
When should I use a t-test versus a z-test?
Use a z-test when the population standard deviation is known and the sample size is large (n > 30). Use a t-test when the population SD is unknown and you estimate it from the sample. For small samples (n < 30), the t-distribution accounts for the extra uncertainty in estimating SD.
What is a chi-square test used for?
The chi-square test compares observed frequencies to expected frequencies in categorical data. A goodness-of-fit test checks if data follows an expected distribution. A test of independence checks if two categorical variables are related. The test statistic increases as observed and expected frequencies diverge.
References
Reviewed by Daniel Agrici, Founder & Lead Developer · Editorial policy