What this calculator does
Every chi-square test in statistics — goodness of fit, independence, homogeneity — reduces to the same distribution math: given a chi-square statistic and degrees of freedom, what does the chi-square distribution say? This calculator answers that question in every direction. Enter χ² and df to get an upper-tail p-value. Enter df and α to get a critical value. Enter a p-value and df to get the χ² that produces that tail area. It also draws the density, generates a critical-value table, and sums (O − E)² / E contributions if you already have observed and expected counts.
Chi-square formula and distribution
The Pearson chi-square statistic is χ² = Σ (O − E)² / E, where O is the observed count in a cell and E is the expected count under the null hypothesis. Each term (O − E)² / E is a contribution, and the statistic is their sum. Every chi-square test uses this same formula applied to a different arrangement of cells. What changes across tests is the degrees of freedom, not the statistic itself.
Under H₀, χ² approximately follows the chi-square distribution with df degrees of freedom. Its density is f(x; k) = x^(k/2 − 1) e^(−x/2) / [2^(k/2) Γ(k/2)] for x ≥ 0. The mean equals k and the variance equals 2k. At low df the shape is strongly right-skewed, with most mass near zero and a long right tail. As k grows the distribution becomes more symmetric and eventually approaches a normal shape.
The upper-tail p-value is the area under the density to the right of the observed statistic. The critical value χ²crit is the cutoff on the statistic such that the area beyond it equals α. Both come from the same distribution — they are two descriptions of the same threshold.
Degrees of freedom in practice
df is not derivable from the statistic. It comes from the study design. Common cases:
- Goodness of fit with k categories and no estimated parameters — df = k − 1.
- Goodness of fit with m parameters estimated from the data — df = k − 1 − m.
- Test of independence in an r × c contingency table — df = (r − 1)(c − 1).
- Test of homogeneity across groups — df = (r − 1)(c − 1).
- McNemar's test, standard 2 × 2 case — df = 1.
Enter df as a whole number. This calculator does not infer it from raw data, because df depends on the design, not on the numbers. If you need to derive df automatically from a contingency table, use a dedicated test calculator.
Worked example
Suppose χ² = 12.4 with df = 4 and α = 0.05.
- Upper-tail p-value: P(X² ≥ 12.4) with df = 4 ≈ 0.0146.
- Critical value: χ²crit at α = 0.05, df = 4 ≈ 9.49.
- Decision: since χ² = 12.4 > 9.49 and p = 0.0146 < 0.05, both the critical-value rule and the p-value rule reject H₀.
What that rejection means substantively depends entirely on the original test. The calculator gives the distribution-level result; whether the result is meaningful for your research question is a separate judgement that only the study design can answer.
Tips and limits
- Always report df alongside χ². A chi-square value alone is not interpretable — χ² = 10 is highly significant at df = 2 and not significant at df = 10.
- Check the expected counts before trusting the approximation. A common rule of thumb is at least 5 in every expected cell. Small expected counts make the chi-square approximation unreliable.
- Do not treat p > α as proof of the null. Failing to reject H₀ is not the same as confirming it. The sample may simply be too small to detect a departure.
- Independence is assumed. Repeated measures, paired data, or clustered sampling violate the assumption and call for different methods like McNemar's test or mixed models.
- This page handles the distribution math only. It does not build contingency tables, compute expected counts, or choose the correct test for your design. Those steps belong to a dedicated test calculator. Fisher's exact test and McNemar's test are also separate methods with their own distributions.