Chi-Square Test Calculator

Enter observed counts, or a contingency table, to test whether they fit what you expect.

One count for each category, separated by commas or spaces.

Optional: one expected count for each category. Leave empty to expect an equal share in each.

Significance levelα\alpha

How unlikely a result must be, if the null hypothesis were true, before it is rejected.

Try

Result

You enteredO={20, 30, 50}O = \left\{ 20,\ 30,\ 50 \right\}

χ2=14, df=2, p=0.000912, reject H0 at the 5% level\displaystyle \chi^2 = 14,\ \text{df} = 2,\ p = 0.000912,\ \text{reject }H_0\text{ at the 5\% level}

p-value

0.000912\displaystyle 0.000912

Significance level

0.05\displaystyle 0.05

Decision

Reject H0\displaystyle \text{Reject } H_0
Show the work
  1. Null and alternative hypotheses

    The null hypothesis H0H_0 says every category is equally likely. The alternative hypothesis H1H_1 is what the test looks for, and it makes this a right-tailed test.

    H0:all categories are equally likelyH1:they are not all equally likely\begin{gathered} H_0: \text{all categories are equally likely} \\ H_1: \text{they are not all equally likely} \end{gathered}
  2. Expected counts

    If every one of the k=3k = 3 categories is equally likely, each expects an equal share of the total N=100N = 100.

    E=Nk=1003≈33.333333\begin{aligned} E &= \frac{N}{k} \\ &= \frac{100}{3} \approx 33.333333 \end{aligned}
  3. Test statistic

    Each category contributes how far its observed count OO is from its expected count EE, squared and scaled by EE. There are k=3k = 3 categories, so ν=k−1=2\nu = k - 1 = 2 degrees of freedom.

    χ2=∑(O−E)2E=163+13+253=14\begin{aligned} \chi^2 &= \sum \frac{\left(O - E\right)^2}{E} \\ &= \frac{16}{3} + \frac{1}{3} + \frac{25}{3} \\ &= 14 \end{aligned}
  4. p-value

    The p-value is the probability, if H0H_0 were true, of a test statistic at least as extreme as the one observed. A chi-square test is always right-tailed: only a large statistic is evidence against the null hypothesis.

    p=P(χ22>14)≈0.000912p = P\left(\chi^2_{2} > 14\right) \approx 0.000912
  5. Decision

    Compare the p-value with the significance level α=0.05\alpha = 0.05: if p<αp < \alpha the result would be too unlikely under H0H_0, so reject it. Here it is, so reject H0H_0: there is enough evidence at the 5% level to say that the categories are not equally likely.

    p=0.000912, α=0.05, p<α⇒reject H0p = 0.000912,\ \alpha = 0.05,\ p < \alpha \Rightarrow \text{reject } H_0
  6. Result

    So χ2=14\chi^2 = 14, p=0.000912p = 0.000912, and the null hypothesis is rejected at the 5% level.

Worked examples