Utinzo

Chi-Square Test Calculator

Calculate the chi-square (χ²) statistic for goodness-of-fit or independence tests. Enter observed and expected frequencies to get χ² and p-value.

Did this tool work for you?

How to use this calculator

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

Sum the squared difference between observed (O) and expected (E) frequencies divided by expected, across all categories.

  1. 1

    Enter observed frequencies (actual counts) for each category.

  2. 2

    Enter expected frequencies (what you would expect under the null hypothesis).

  3. 3

    The calculator returns χ² and the p-value for df = categories − 1.

  4. 4

    If p < α, the observed distribution significantly differs from expected.

Frequently asked questions

What is the chi-square test used for?

A goodness-of-fit test compares observed category counts with the counts a hypothesis expects. A test of independence asks whether two categorical variables are related. This tool computes the statistic for a three-category goodness-of-fit comparison only.

How are the degrees of freedom set?

The tool always uses three categories, so df is fixed at 2 (categories minus 1) and the Degrees of freedom row always shows 2. There is no way to change it, so a table with another shape needs a different tool.

How is the p-value calculated, and is it exact?

For 2 degrees of freedom the upper-tail probability has a closed form, p = e^(−χ²/2), and the tool uses it, so the value is exact apart from display rounding to four decimals. For χ² = 5.00 it returns 0.0821, and below 0.0001 it prints “< 0.0001”. An earlier normal approximation returned 0.0800 for that case and 0.9962 instead of 1.0000 for a perfect match.

How is the decision line chosen?

It compares the p-value with the significance level in the last box. If p is below α the line reads “Reject H₀ at α=…”, otherwise “Fail to reject H₀ at α=…”. An α of 0, an emptied box, or any value of 1 or more returns “Significance level must be between 0 and 1”.

What inputs are rejected?

Any expected count at 0 or below returns “All expected frequencies must be positive”, because it would divide by zero, and an emptied expected box counts as 0. A negative observed count returns “Observed frequencies cannot be negative”. An observed count of 0 is allowed and contributes its full expected value to χ².

Should the observed and expected totals match?

They should, but the tool does not check. Entering 70, 20, 10 against expected 40, 40, 20 works because both total 100. Mismatched totals still produce a number, but it no longer describes a proper goodness-of-fit test. Enter counts, not percentages, since percentages change the statistic.

Can I use it for a contingency table?

Only to get the statistic. The tool does not build expected counts from row and column totals, and its p-value assumes 2 degrees of freedom, whereas a 2×2 table has 1 and a 3×3 table has 4. Compare your own total with the critical values on this page for the correct df.

What sample size does the test need?

The usual guideline is an expected count of at least 5 in each category. The tool does not enforce it, so a result with small expected counts still prints. A significant result also shows that a difference exists, not how large it is.

About chi-square test calculator

Chi-Square Test Calculator — χ² Statistic & P-Value

When to use the chi-square test

Use the goodness-of-fit chi-square test to compare an observed frequency distribution against a theoretical one — for example, checking if dice rolls are fair. Use the chi-square test of independence to test whether two categorical variables (like gender and voting preference) are related.

Assumptions and limitations

Chi-square tests require: independent observations; categorical data; expected frequencies of at least 5 per cell. The test tells you whether a difference exists, not how large or important the difference is — combine it with effect size measures like Cramér's V.

Worked example: does the observed split match what we expected?

Suppose 100 people choose among three options and you expected a 40 / 40 / 20 split, but observed 50 / 30 / 20. Add up (O − E)² / E for each category: 2.50 + 2.50 + 0.00 = 5.00, with 3 − 1 = 2 degrees of freedom. The calculator reports p = 0.0821, computed as e^(−5.00 ÷ 2). That is above 0.05, so you fail to reject the null hypothesis: the difference could be chance.

Chi-square working for the example
CategoryObserved (O)Expected (E)(O − E)² / E
150402.50
230402.50
320200.00
Total1001005.00

An example that rejects the null hypothesis

If the observed counts were 70 / 20 / 10 against the same expected 40 / 40 / 20: (30)² / 40 + (20)² / 40 + (10)² / 20 = 22.50 + 10.00 + 5.00 = 37.50 with 2 degrees of freedom. The calculator prints p as “< 0.0001”, so you reject the null hypothesis: the observed split differs significantly from the expected one.

Chi-square critical values

You can decide without a p-value: if your χ² statistic is larger than the critical value for your degrees of freedom and significance level, reject the null hypothesis. For 2 degrees of freedom at α = 0.05 the critical value is 5.991, so the first example (5.00) falls just short and the second (37.50) is far above it.

Upper-tail critical values of the chi-square distribution
Degrees of freedomα = 0.10α = 0.05α = 0.01
12.7063.8416.635
24.6055.9919.210
36.2517.81511.345
47.7799.48813.277
59.23611.07015.086
610.64512.59216.812
813.36215.50720.090
1015.98718.30723.209

Limits of this calculator and common mistakes

This calculator handles three categories (df = 2), and its p-value formula is exact for that case. A smaller example from the tool: observed 18 / 22 / 20 against expected 20 / 20 / 20 gives χ² = 0.4000 and p = 0.8187. For more categories, add up the (O − E)² / E terms yourself and compare the total with the table above. Enter counts, not percentages: percentages change the χ² value. Make sure the observed and expected totals match, because the tool does not check, and keep every expected count at 5 or more. Entries that fail validation return a message: a zero expected count, a negative observed count, or a significance level outside 0 to 1.

Chi-Square Test Calculator – Utinzo

Learn more from an authoritative source:

Wikipedia
Related tools

Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →