Chi-Square Goodness of Fit Calculator
Check whether a set of observed category counts is consistent with hypothesized expected counts or proportions using the chi-square goodness-of-fit test.
Fail to reject H0: fits expected (p ≥ 0.05)
- 1
Number of categories (k)
5 - 2
Degrees of freedom (df = k − 1)
5 − 1 = 4 - 3
Chi-square χ² = Σ (O − E)² ÷ E
Sum over 5 categories = 2.9000Each term (Oᵢ − Eᵢ)² ÷ Eᵢ is summed; categories with the largest relative deviations contribute most.
How does this calculator work?
The chi-square goodness-of-fit test compares observed category counts to expected counts or proportions using χ² = Σ(Oᵢ−Eᵢ)²/Eᵢ with df = k−1. A small p-value (below 0.05) means the observed data differ significantly from what was expected, so you reject the null hypothesis of a good fit.
Formula
How this is calculated
Enter the observed counts (Oᵢ) for each of k categories and the matching expected values. Expected values may be given as raw counts or as proportions; if the expected entries sum to approximately 1 they are treated as proportions and scaled by the total observed count so that Eᵢ = pᵢ · ΣO. Both lists must have the same length and contain non-negative numbers.
The test statistic is χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ, summed across all categories. Each term measures the squared deviation between observed and expected, standardized by the expected count, so categories with large relative discrepancies contribute most. The degrees of freedom equal k − 1, where k is the number of categories. The p-value is the upper-tail area of the chi-square distribution with that many degrees of freedom, computed here from the regularized upper incomplete gamma function Q(df/2, χ²/2).
The null hypothesis H0 states that the observed counts follow the expected distribution. At a significance level of α = 0.05 we reject H0 when p < 0.05, indicating the data differ from expectation; otherwise we fail to reject. The chi-square approximation assumes a reasonable sample size — a common rule is that every expected count should be at least 5. Expected counts of zero are invalid because they would divide by zero, and the test is not reliable for very sparse tables.
Frequently asked questions
Either works. If your expected entries sum to about 1 they are interpreted as proportions and multiplied by the total observed count; otherwise they are used directly as expected counts.
For a goodness-of-fit test with k categories the degrees of freedom are k − 1, because the expected counts are constrained to match the observed total.
A p-value below 0.05 means the observed counts deviate from the expected distribution more than would be likely by chance, so you reject the null hypothesis of a good fit.
Also known as
TG we-Calculate Editorial Team. (2026). Chi-Square Goodness of Fit Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/chi-square-goodness-of-fit-calculator
TG we-Calculate Editorial Team. "Chi-Square Goodness of Fit Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/chi-square-goodness-of-fit-calculator.
TG we-Calculate Editorial Team, "Chi-Square Goodness of Fit Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/chi-square-goodness-of-fit-calculator
@misc{wecalculate_chi_square_goodness_of_fit_calculator, title = {Chi-Square Goodness of Fit Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/chi-square-goodness-of-fit-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
