Chi-Square Goodness-of-Fit
Chi-square = sum((observed - expected)^2 / expected) on k-1 df, the p-value from the chi-square CDF.
Example
You enter
- Observed counts (comma or whitespace separated) 10, 20, 30, 40
- Expected (same number of categories) 25, 25, 25, 25
- Expected values are counts
- Significance level (alpha) 0.05
You get
- Chi square 20
- Degrees of freedom 3
- P value 0.0001699
Details, formula, and sources
Chi-square = sum((observed - expected)^2 / expected) on k-1 df, the p-value from the chi-square CDF, and a reject / fail-to-reject verdict at alpha. Expected entered as counts or proportions; flags expected counts below 5. Per OpenIntro Statistics Ch. 6.
Chi-square statistic = sum((observed - expected)^2 / expected) over k categories, on k - 1 degrees of freedom. p-value = 1 - chi2Cdf(chi-square, k - 1). Expected proportions are scaled to the observed total. Reject H0 (the observed counts follow the expected distribution) when p < alpha.
OpenIntro Statistics 4th ed. Chapter 6 (inference for categorical data) by name; the chi-square CDF via the regularized lower incomplete gamma function per Numerical Recipes in C 2nd ed. §6.2.
OpenIntro Statistics free at openintro.org; Numerical Recipes chapters free at numerical.recipes.
Estimate only. Readability formulas and similar metrics are derived from a representative population and have known edge-case noise. The classroom teacher governs final text selection, grade placement, and assessment decisions.
Field names used by the API: observed, expected, expected_type, alpha, chi_square, df, p_value
- Degrees of freedom k - 1 (goodness-of-fit, one constraint: counts sum to the total)OpenIntro Statistics Ch. 6
- Expected-count floor every expected count should be at least 5 for the approximationCochran's rule
- Chi-square CDF regularized lower incomplete gamma P(df/2, x/2)Numerical Recipes 6.2