statistics calculators

Chi-Square Test Calculator

Compute the chi-square test statistic to determine if observed frequencies differ significantly from expected ones. Commonly used in genetics, market research, and any test of independence or goodness of fit.

About this calculator

The chi-square (χ²) statistic measures how much observed counts deviate from expected counts under a null hypothesis. For each category, the contribution is: χ² = (O − E)² / E, where O is the observed frequency and E is the expected frequency. The total chi-square statistic is the sum of these contributions across all categories: χ²_total = Σ [(Oᵢ − Eᵢ)² / Eᵢ]. A larger χ² value means observed data deviates more from expectations. To determine statistical significance, compare χ²_total against a critical value from the chi-square distribution with degrees of freedom df = k − 1, where k is the number of categories. If χ²_total exceeds the critical value at your chosen significance level (e.g., 0.05), you reject the null hypothesis of no difference. Expected frequencies should generally be at least 5 per category for the test to be valid.

How to use

Suppose you roll a die 60 times and observe: 8, 9, 12, 11, 10, 10. The expected count for each face is 60/6 = 10. For each category: (8−10)²/10 = 0.4, (9−10)²/10 = 0.1, (12−10)²/10 = 0.4, (11−10)²/10 = 0.1, (10−10)²/10 = 0, (10−10)²/10 = 0. χ²_total = 1.0. Enter observed = 8, expected = 10 per category, categories = 6. The calculator computes the per-cell statistic as (8−10)²/10 = 0.4; sum all six contributions to get χ² = 1.0, well below the critical value of 11.07 at α = 0.05 (df = 5).

Frequently asked questions

What is the difference between chi-square goodness of fit and chi-square test of independence?

The goodness-of-fit test checks whether a single categorical variable follows a hypothesized distribution, such as whether a die is fair. The test of independence checks whether two categorical variables are related, such as whether gender and product preference are associated. Both use the same χ² = Σ(O−E)²/E formula, but they differ in how expected frequencies are calculated and how degrees of freedom are determined. For the test of independence, df = (rows − 1) × (columns − 1), while for goodness of fit, df = k − 1 where k is the number of categories.

How do I find the expected frequency for a chi-square test?

For a goodness-of-fit test, the expected frequency for each category is simply the total sample size multiplied by the hypothesized proportion for that category. For a test of independence in a contingency table, the expected frequency for a cell is E = (row total × column total) / grand total. The expected frequencies represent what you would observe if the null hypothesis were true — that is, if the distribution matched your hypothesis or if the two variables were completely independent. All expected frequencies should be at least 5; if some are smaller, consider combining categories or using Fisher's exact test instead.

When should I reject the null hypothesis in a chi-square test?

Reject the null hypothesis when the computed χ² statistic exceeds the critical value for your chosen significance level (usually α = 0.05) and the appropriate degrees of freedom, or equivalently when the p-value is less than α. For example, with 3 categories (df = 2) at α = 0.05, the critical value is 5.991; a χ² of 7.5 would lead to rejection. Rejecting the null means the observed frequencies are unlikely to have occurred by chance under the null model. It does not tell you which categories drive the discrepancy — examine the individual (O−E)²/E contributions to identify where the largest deviations occur.