Advanced

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.
Comma or space separated counts for each category
Same number of values; proportions summing to 1 are auto-scaled
Chi-square statistic
2.9000

Fail to reject H0: fits expected (p ≥ 0.05)

Degrees of freedom
4
p-value
0.5747
Categories
5
Total observed
100
Decision (α = 0.05)
Fail to reject H0
Observed 118
Expected 120
Observed 222
Expected 220
Observed 320
Expected 320
Observed 425
Expected 420
Observed 515
Expected 520
Step by step
  1. 1

    Number of categories (k)

    5
  2. 2

    Degrees of freedom (df = k − 1)

    5 − 1 = 4
  3. 3

    Chi-square χ² = Σ (O − E)² ÷ E

    Sum over 5 categories = 2.9000
    Each term (Oᵢ − Eᵢ)² ÷ Eᵢ is summed; categories with the largest relative deviations contribute most.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

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
χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ, df = k − 1
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

chi square goodness of fit
chi square test
goodness of fit test
observed expected frequencies
chi squared calculator
chi square gof
x2 test
categorical fit test

APA

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

Chicago

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.

IEEE

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

BibTeX

@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?