
Does Your Data Fit the Expected Distribution?
You rolled a die 60 times and the sixes keep coming up. Is the die fair, or are you just noticing streaks? The chi-square goodness-of-fit test answers exactly this kind of question: it measures how far your observed counts stray from the expected counts — and whether the gap could plausibly be chance.
This chi-square calculator takes your observed and expected frequencies and returns the χ² statistic, degrees of freedom, an exact p-value and a plain-English decision at your chosen significance level — with every category’s contribution shown step by step.
χ² goodness of fit · statistic · p-value · decision
? What does the chi-square goodness-of-fit test do?
It asks: do my observed counts plausibly come from the expected distribution? For each category it computes (observed − expected)² / expected and adds them up. A small total means the data fit well; a large total means they don’t.
The p-value is the probability of seeing a statistic this large if the expected distribution were true. If p < α, reject the null hypothesis (the data do not fit). The test needs expected counts of at least 5 per category to be reliable.
Please enter at least 2 positive observed values (comma-separated numbers). Expected values, if given, must match in count and all be positive.
| Cat. | Observed | Expected | (O−E)²/E |
|---|
Educational tool. The chi-square approximation needs expected counts of 5+ per category; with smaller counts, combine categories or use Fisher’s exact test. A non-significant result means “no evidence against the expected distribution” — not proof it is exactly right.
How to Use the Chi-Square Calculator
- Enter observed frequencies as comma-separated counts (e.g. 8, 12, 9, 14, 11, 6).
- Enter expected frequencies — or leave blank for equal expectations across categories.
- Pick your significance level α (0.05 is the standard).
- Click Run Chi-Square Test.
- Read the verdict: the statistic, p-value, per-category contributions and whether to reject the null hypothesis.

The Chi-Square Formula
Degrees of freedom: df = k − 1 (k = number of categories)
p-value = P(χ² ≥ observed | df), from the chi-square distribution
Worked example: die rolled 60 times, observed 8, 12, 9, 14, 11, 6; expected 10 each. χ² = (8−10)²/10 + (12−10)²/10 + … = 0.4 + 0.4 + 0.1 + 1.6 + 0.1 + 1.6 = 4.2, df = 5, p ≈ 0.52. Since 0.52 > 0.05, fail to reject — no evidence the die is unfair.
Reading Your Result
| p-value | Meaning | Decision (at α = 0.05) |
|---|---|---|
| p < 0.01 | Strong evidence against the expected distribution | Reject H₀ |
| 0.01 – 0.05 | Moderate evidence against it | Reject H₀ |
| 0.05 – 0.10 | Weak evidence | Fail to reject |
| p > 0.10 | Little or no evidence against it | Fail to reject |
Where the Goodness-of-Fit Test Is Used
Biology and genetics test whether observed trait ratios match Mendelian expectations. Marketing checks whether survey responses match population proportions. Quality control verifies defect counts against expected rates. Students meet it in every intro stats course — usually with dice, coins or M&Ms.
One rule keeps the test honest: every expected count should be at least 5. Below that, the chi-square approximation wobbles — combine sparse categories or use Fisher’s exact test instead. The calculator warns you automatically.
Worked Example: Test of Independence (Contingency Table)
The goodness-of-fit test handles one variable. When you have two categorical variables, the same χ² machinery becomes a test of independence. Example: a café chain surveys 200 customers — 100 morning, 100 evening — about their preferred drink. Expected counts come from the table itself: E = row total × column total ÷ grand total. Because both row totals are 100 and the column totals are 50, 70 and 80, every row expects 25, 35 and 40.
| Tea | Coffee | Juice | |
|---|---|---|---|
| Morning | 20 (E 25) | 30 (E 35) | 50 (E 40) |
| Evening | 30 (E 25) | 40 (E 35) | 30 (E 40) |
Now the six cell contributions: (20−25)²/25 = 1.00, (30−35)²/35 = 0.71, (50−40)²/40 = 2.50, (30−25)²/25 = 1.00, (40−35)²/35 = 0.71, (30−40)²/40 = 2.50. They sum to χ² = 8.43. Degrees of freedom for a table are (rows − 1)(columns − 1) = (2−1)(3−1) = 2, giving p ≈ 0.015. Since 0.015 < 0.05, reject independence — drink preference really is associated with time of day, with juice skewing morning.
Running this table through the calculator above: flatten it row by row — observed 20, 30, 50, 30, 40, 30 with expected 25, 35, 40, 25, 35, 40. The widget will report the same χ² of 8.43, but it counts six categories and shows df = 5; for a contingency table, interpret the result with the table’s own df = 2.
Chi-Square Critical Values at a Glance
No p-value handy? Compare your statistic with the critical value for your degrees of freedom: if χ² exceeds it, the result is significant at that level.
| df | α = 0.10 | α = 0.05 | α = 0.01 |
|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 |
| 2 | 4.605 | 5.991 | 9.210 |
| 3 | 6.251 | 7.815 | 11.345 |
| 4 | 7.779 | 9.488 | 13.277 |
| 5 | 9.236 | 11.070 | 15.086 |
| 6 | 10.645 | 12.592 | 16.812 |
Cross-check the earlier example: χ² = 8.43 at df = 2 clears the 5.991 bar for α = 0.05 — the same significant verdict the p-value of 0.015 delivered, reached from the other direction.
Common Mistakes That Invalidate a Chi-Square Test
- Feeding in percentages instead of counts. The test needs raw frequencies. Entering 20% instead of the 20 people it represents destroys the sample-size information the statistic depends on.
- Expected counts below 5. The chi-square approximation gets unreliable when expected cells are tiny. Combine sparse categories or switch to Fisher’s exact test.
- Reading “fail to reject” as proof. A non-significant result means no evidence against the expected distribution — not confirmation it is exactly right, especially with small samples.
- Testing continuous data without binning. Heights, incomes and times must first be grouped into categories; the test only works on counts in discrete buckets.
Frequently Asked Questions
What is the chi-square goodness-of-fit test?
It tests whether observed categorical counts plausibly come from an expected distribution. The statistic χ² = Σ(O−E)²/E grows as observations diverge from expectations; a p-value then judges whether the gap could be chance.
How do you calculate chi-square by hand?
For each category compute (observed − expected)² ÷ expected, then add them all up. Degrees of freedom = number of categories minus 1. Compare the total to a chi-square table or convert it to a p-value.
What does the p-value mean in a chi-square test?
The probability of seeing a statistic this large if the expected distribution were really true. Small p (below your α, usually 0.05) means the data do not fit — reject the null hypothesis.
What are the assumptions of the chi-square test?
Data must be counts (not percentages or means), categories mutually exclusive, observations independent, and expected counts at least 5 per category.
What is the difference between goodness-of-fit and test of independence?
Goodness-of-fit compares one set of observed counts to an expected distribution. The test of independence uses a contingency table to ask whether two categorical variables are related — same χ² machinery, different setup.
Can chi-square prove my distribution is correct?
No. Failing to reject the null means “no evidence against it,” not proof it is exactly right — especially with small samples, which lack the power to detect real differences.
Can the chi-square statistic be negative?
No. Every term in χ² = Σ(O−E)²/E is a squared difference divided by a positive expected count, so each term is zero or positive and the total can never drop below zero. A χ² of exactly 0 means observed and expected counts matched perfectly in every category.
What is a good chi-square value?
There is no single good value — it depends on the degrees of freedom. A small χ² (with a large p-value) means your data hug the expected distribution closely; a large χ² means a poor fit. Judge yours against the critical value for your df: below it, the deviation is consistent with chance; above it, the difference is statistically significant.
How do I calculate chi-square in Excel?
Use =CHISQ.TEST(actual_range, expected_range) to get the p-value directly from two ranges of counts. If you already have the statistic, =CHISQ.DIST.RT(χ² value, df) returns its p-value, and =CHISQ.INV.RT(0.05, df) gives the critical value to compare it against.
Final Thoughts
The chi-square test turns “this looks off” into a number you can defend. Feed it honest counts, respect the expected-≥5 rule, and let the p-value — not your gut — deliver the verdict.
Tested Your Fit? Go Deeper Into Stats
Continue with our standard deviation calculator and percentage calculator.