Chi-Square Distribution Calculator

Calculate p-value from a chi-square test statistic and degrees of freedom.
Shows the right-tail probability and plots the chi-square PDF with critical region.

Chi-Square Distribution

The chi-square distribution is a family of right-skewed probability distributions, one for each number of degrees of freedom. It shows up constantly in statistics: goodness-of-fit tests, tests of independence in contingency tables, and variance inference all rely on it.

The distribution is defined only for non-negative values. With small degrees of freedom it is heavily right-skewed; as degrees of freedom grow it approaches a normal distribution, centered around df and with variance 2·df.

This calculator takes a chi-square statistic and degrees of freedom, then returns the right-tail p-value — the probability of observing a chi-square value at least as large as yours, assuming the null hypothesis is true. A p-value below 0.05 is conventionally “statistically significant.”

The right-tail area is the regularized upper incomplete gamma function, evaluated at half your inputs:

p-value = Q(df/2, χ²/2)

The calculator computes that directly rather than approximating it. A power series handles the case where χ²/2 is small relative to df/2, and a continued fraction takes over above that point. Both run to full double precision, so the number you get back is the actual tail area rather than a curve fitted to it.

That matters more than it sounds. The Wilson-Hilferty cube-root approximation, which a lot of online calculators still use, returns 0.0487 for the classic df=2 critical value of 5.99 instead of 0.0500. Fine for a rough read, awkward when you are checking your work against a textbook.

Common critical values for reference:

  • df=1: χ² = 3.84 gives p = 0.05; χ² = 6.63 gives p = 0.01
  • df=2: χ² = 5.99 gives p = 0.05; χ² = 9.21 gives p = 0.01
  • df=5: χ² = 11.07 gives p = 0.05; χ² = 15.09 gives p = 0.01

One quirk to expect if you type those straight in. Printed tables round the critical value down, so the real df=1 boundary is 3.8415 while the table prints 3.84, and entering 3.84 comes back as p = 0.050044. That is a hair on the wrong side of the line, so the calculator calls it marginal rather than significant. The table is what got rounded, not the arithmetic, and it is a decent illustration of why a borderline p-value is a bad thing to hang a conclusion on.

The chart plots the chi-square PDF for your chosen degrees of freedom, shading the right-tail region that corresponds to the p-value.

Computing the χ² statistic from data

If you have observed counts and need to compute the chi-square statistic itself before entering it above, the formula is:

χ² = Σ (O − E)² / E

where O is the observed count in each category, E is the expected count under the null hypothesis, and the sum runs over all categories. Degrees of freedom for a goodness-of-fit test = (number of categories − 1).

Worked example — is a die fair? A die is rolled 60 times. Under a fair-die null hypothesis, each face is expected 10 times. Observed counts: 8, 12, 11, 7, 13, 9.

  • Each contribution: (8−10)²/10 = 0.4; (12−10)²/10 = 0.4; (11−10)²/10 = 0.1; (7−10)²/10 = 0.9; (13−10)²/10 = 0.9; (9−10)²/10 = 0.1
  • Sum: χ² = 2.8
  • df = 6 − 1 = 5
  • The critical value at α = 0.05 for df = 5 is 11.07; 2.8 is well below, so we fail to reject the null. The die looks fair.

A second example — survey preferences. 200 people are asked their favourite season; the null hypothesis is equal preference (50 each). Observed: Spring 65, Summer 55, Autumn 45, Winter 35.

  • χ² = 15²/50 + 5²/50 + (−5)²/50 + (−15)²/50 = 4.5 + 0.5 + 0.5 + 4.5 = 10.0
  • df = 4 − 1 = 3; critical value at α = 0.05 is 7.815
  • χ² = 10.0 > 7.815, so we reject the null. There is a real seasonal preference.

Rule of thumb that catches a lot of bad chi-square work: each expected count E should be at least 5. With smaller expected counts the chi-square approximation breaks down and a Fisher exact test is the better tool.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.