Chi-Square Goodness of Fit Calculator
Tests whether your observed frequency counts match a theoretically expected distribution. Use it to check if a die is fair, verify that survey responses follow a predicted pattern, or validate a statistical model.
About this calculator
The chi-square goodness-of-fit test quantifies how much observed frequencies deviate from expected frequencies under a null hypothesis. The test statistic is χ² = Σ [(Oᵢ − Eᵢ)² / Eᵢ], summed over all categories i, where Oᵢ is the observed count and Eᵢ is the expected count. For two categories this simplifies to χ² = (O₁ − E₁)² / E₁ + (O₂ − E₂)² / E₂. The resulting χ² value is compared to a critical value from the chi-square distribution with df = k − 1 degrees of freedom, where k is the number of categories. A large χ² indicates the observed data are unlikely under the null hypothesis. The p-value gives the probability of obtaining a χ² this large by chance alone; if p < α you reject the null. Each expected cell count should be at least 5 for the approximation to be valid.
How to use
A six-sided die is rolled 60 times. You expect each face 10 times. Suppose face 1 appears 14 times and face 2 appears 6 times (simplifying to two categories here). Step 1 — enter O₁ = 14, E₁ = 10, O₂ = 6, E₂ = 10. Step 2 — compute: (14−10)²/10 + (6−10)²/10 = 16/10 + 16/10 = 1.6 + 1.6 = 3.2. Step 3 — with df = 1 and α = 0.05 the critical value is 3.841. Since χ² = 3.2 < 3.841, you fail to reject the null hypothesis — no strong evidence the die is unfair.
Frequently asked questions
What are the assumptions required for a chi-square goodness of fit test?
The test requires that observations are independent of one another and that data are counts (not percentages or means). Each expected frequency Eᵢ should be at least 5; if cells have smaller expectations, consider combining adjacent categories or using an exact test. The test is also only appropriate when data are categorical or grouped into discrete categories. Violating these assumptions inflates the Type I error rate and makes the p-value unreliable.
How do degrees of freedom affect the chi-square goodness of fit test?
Degrees of freedom equal the number of categories minus one (df = k − 1) for a basic goodness-of-fit test, or minus additional estimated parameters when you fit a distribution from the data. Higher df shifts the chi-square distribution rightward, raising the critical value needed for significance. Using the wrong df — a common mistake when parameters are estimated — leads to incorrect p-values. Always subtract one additional degree of freedom for each parameter estimated from the sample.
What is the difference between a chi-square goodness of fit test and a chi-square test of independence?
The goodness-of-fit test compares a single variable's observed frequencies against a theoretical distribution (e.g., uniform, Poisson). The test of independence examines whether two categorical variables in a contingency table are associated. Both use the same χ² = Σ (O − E)² / E formula, but degrees of freedom differ: goodness of fit uses df = k − 1, while independence uses df = (rows − 1) × (columns − 1). Choosing the wrong test leads to incorrect inference, so always identify whether you have one variable or two.