You solve a chi-square goodness-of-fit test by comparing observed counts to expected counts, then turning those gaps into one test statistic and one decision. The whole method rests on four things: a claimed distribution, a sample size, categories, and a chi-square value that you compare to a table or p-value. Start with the claim. If a bag of 100 candies should be 25% red, 25% blue, 25% green, and 25% yellow, then the expected count for each color is 25. If a die should land on each face about 1/6 of the time, a sample of 60 rolls gives an expected 10 per face. That is the heart of the test. You do not ask whether the counts look a little off. You ask whether the gaps are small enough to blame on random chance. The test works best when the data come from a random sample, the observations stay independent, and the expected counts stay large enough for the chi-square shape to work well. Most intro stats classes use the rule that expected counts should be at least 5 in each category. A principles of statistics course treats this as a standard check, not a side note. Skip it, and the result can wobble. The math itself stays simple once you know the flow: find expected counts, compute (O−E)^2/E for each category, add them up, then compare the total to a chi-square curve with the right degrees of freedom. The trick is not the arithmetic. It is matching the numbers to the claim with enough care that the final conclusion means something in real life.
How Do You Set Up Chi-Square Goodness-of-Fit?
Set up a chi-square goodness-of-fit test by naming the claimed distribution, listing the categories, and turning each probability into an expected count from the sample size. If a bag claim says 20%, 30%, 25%, and 25% across 4 colors and you sample 200 items, the expected counts are 40, 60, 50, and 50. That is the first move every time.
The observed counts come next. You record what you actually saw, such as 44 red, 55 blue, 49 green, and 52 yellow, then line them up beside the expected values. The test does not care about raw drama. It cares about whether the differences stay small enough that chance can explain them.
The catch: The setup only works cleanly when the sample is random, the 200 observations stay independent, and the expected counts reach at least 5 in each cell. That 5-count rule shows up in most principles of statistics classes because the chi-square curve acts badly with tiny expected numbers. If one category only expects 1.8 cases, the approximation gets shaky fast.
Write the hypotheses in plain words before you touch the formula. H0 says the data follow the claimed distribution. H1 says at least one category differs. A die example makes this easy: if you roll 60 times, the fair-die claim gives 10 per face, and 6 faces give you 6 expected counts of 10. That setup is enough to start the test and avoid sloppy guessing.
A lot of students rush past the claim and jump straight to calculation. Bad habit. If you cannot state the distribution in one sentence, you probably do not know what the test checks. For more practice with this setup in a principles of statistics course, see Principles of Statistics.
One more thing: if a category combines into a tiny leftover group, think twice before you keep it. A 3% expected slice inside a 100-person sample gives you only 3 expected cases, which fails the usual rule. That small number can distort the whole test, and the math will not save a weak setup.
Chi-Square: Exam vs Course?
A chi-square problem can show up as a one-shot exam question or as a course-based credit path. The exam path usually gives you one timed sitting and one score to live with. The course path gives you multiple checks, more review, and a transcriptable credit result that can move as transferable credit at cooperating schools. That difference matters if you want fewer sharp edges.
| Row | Chi-Square Exam | NCCRS & ACE-Recommended Statistics Course |
|---|---|---|
| Where to take it | College Board | UPI Study |
| Format | Timed test, 1 sitting | Course with lessons + checks |
| Pace | Fixed test date | Fully self-paced |
| Cost | Varies by exam type | $250 per course or $99/month |
| Review | One retake after waiting period | Unlimited review, no deadlines |
| Credit result | Exam-based credit policy | ACE and NCCRS approved; transferable credit |
Reality check: The course route gives you more than comfort. It gives you 90+ college-level courses, 2 recognition paths through ACE and NCCRS, and credit that transfers at partner US and Canadian colleges. That matters more than a flashy test day if your goal is college credit, not just a score. For more on the statistics side, Principles of Statistics keeps the core ideas in one place.
Learn Principles Of Statistics Online for College Credit
This is one topic inside the full Principles Of Statistics course on UPI Study — a self-paced, online class that earns real college credit. Credits are ACE and NCCRS evaluated and transfer to partner colleges across the US and Canada. Courses start at $250 with no deadlines and lifetime access.
Browse Principles Of Statistics →How Do You Calculate the Chi-Square Test Statistic?
Use \u03c7\u00b2 = \u2211((O-E)^2/E), where O means observed count and E means expected count. Here is a full example with 4 categories. A store thinks customer choices follow 25%, 25%, 25%, and 25% across four snack types. It samples 80 purchases and gets observed counts of 30, 18, 17, and 15. The expected counts are 20, 20, 20, and 20.
Build a small table in your notes. Category 1 contributes (30-20)^2/20 = 100/20 = 5. Category 2 gives (18-20)^2/20 = 4/20 = 0.2. Category 3 gives (17-20)^2/20 = 9/20 = 0.45. Category 4 gives (15-20)^2/20 = 25/20 = 1.25. Add them: 5 + 0.2 + 0.45 + 1.25 = 6.90.
That 6.90 is the test statistic. Bigger gaps make bigger contributions because you square the difference before you divide by expected count. A 10-count miss counts far more than a 2-count miss, and that is exactly what the formula should do. I like this part of the test because it punishes wild mismatch without getting fooled by tiny wiggles.
Round carefully. Keep expected counts to at least 2 decimals if you can, but do not round the final test statistic until the end. If one step gives 0.225, keep it as 0.225 in your scratch work and round only the final sum if your class asks for 2 decimals. That habit saves annoying errors when you compare values around 7.78 or 9.49.
A second quick example helps. If a 6-face die gives observed counts of 14, 8, 9, 11, 7, and 11 out of 60 rolls, the expected count stays 10 for each face. You can compute six small terms, then add them into one chi-square value. The pattern stays the same every time, and the arithmetic stays honest. For extra practice, a principles of statistics course often uses the same template across multiple chapter problems, and this statistics course follows that same structure.
How Do You Find Degrees of Freedom and P-Value?
Degrees of freedom for a chi-square goodness-of-fit test usually equal the number of categories minus 1, because once you know 5 category counts in a 6-category problem, the last one gets fixed by the total sample size. If you estimate 1 parameter from the data, subtract 1 more. That means 6 categories with no estimated parameters gives df = 5, while 6 categories with 1 estimated parameter gives df = 4. The p-value then comes from the chi-square curve with that df, not from guesswork.
If your test statistic equals 6.90 from the 4-category snack example, then df = 3. At alpha = 0.05, the critical value sits near 7.815 for df = 3. Since 6.90 stays below 7.815, you fail to reject the null hypothesis. The p-value lands above 0.05, so the sample does not give strong evidence against the claimed distribution.
- 4 categories give df = 3.
- 6 categories give df = 5.
- One estimated parameter cuts df by 1.
- At alpha 0.05, compare to the critical value.
- A p-value below 0.05 means reject H0.
How Do You Interpret Chi-Square Goodness-of-Fit Results?
Interpret the result by translating the math into plain words. If you fail to reject H0, your sample looks consistent with the claimed distribution. If you reject H0, the data do not fit that claim well. That sentence should sound calm, not dramatic.
Suppose a survey claims 40%, 35%, and 25% preferences for 3 menu items in a sample of 120 people. If your test gives p = 0.18, you fail to reject at 0.05. Your conclusion can say, "The observed menu choices are consistent with the claimed distribution." That means the gaps you saw could easily come from random sampling.
Now flip it. A die rolled 120 times should give about 20 on each face if it is fair. If your test gives p = 0.01, you reject the fair-die claim. A clean conclusion says, "The observed counts differ from a fair die distribution at the 5% level." That wording beats sloppy phrases like "the die is definitely rigged," because statistics never gives you that much theater.
Bottom line: Write the decision, the alpha level, and the context in one sentence. "At alpha = 0.05, we reject the claim that customer choices follow the 25%-25%-25%-25% model." That sentence works because it names the test, the threshold, and the real-world idea all at once. A weak conclusion leaves out one of those pieces and sounds half-finished.
A nice habit helps here. If the numbers are close, say so. If one category explodes, say that too. A chi-square result with 8 categories and a p-value of 0.62 tells a very different story from one with 8 categories and a p-value of 0.003, and your wording should match that gap exactly.
Frequently Asked Questions about Chi Square Goodness Of Fit
Use the formula χ² = Σ((O−E)²/E) across all 4 categories, then compare your result with df = 3. If you have counts like 18, 22, 24, and 16 out of 80, you first turn the claimed proportions into expected counts and then add the four pieces of the test statistic.
You solve them by multiplying the total sample size by each claimed proportion, then plugging observed and expected counts into χ² = Σ((O−E)²/E). Unequal expected counts are normal, and the chi-square test still works as long as the expected counts come from the claimed distribution.
The most common wrong assumption is that you compare observed counts to percentages instead of expected counts. You need actual expected frequencies, like 12.5 or 27.2, because the chi-square test uses counts, not proportions, in every category.
If you get df wrong, your p-value or critical-value cutoff will point you to the wrong decision. For k categories, you use df = k − 1, so 6 categories give df = 5, and that changes which chi-square value you compare against.
Start by writing the null claim and turning it into expected counts from the sample size. If a die should be fair, you use 1/6 for each face and, with 60 rolls, you expect 10 per face before you calculate χ².
This applies to you if you have one categorical variable with 2 or more groups, like colors, die faces, or response choices; it doesn't fit paired data or two-variable association problems. In a principles of statistics course, this test sits beside goodness-of-fit examples, not independence tests.
What surprises most students is that a large chi-square value means a worse fit, not a better one. If your expected counts are 8, 8, and 8 but your observed counts are 2, 8, and 22, the gaps drive χ² upward fast.
Most students start by hunting for the p-value, but what actually works is filling in O, E, and (O−E)²/E for every category first. Once you have the total χ², the p-value step takes 1 lookup on a chi-square table or calculator.
You say the sample does or doesn't match the claimed distribution at your chosen α level, like 0.05, and then tie that to the setting. If voters, colors, or die rolls don't fit the claim, you describe that mismatch in plain words, not just as a statistic.
An online course in principles of statistics can give you graded practice on chi-square tables, p-values, and expected counts, and some options carry ACE NCCRS credit or transferable credit. That matters if you want college credit while you study online and move at your own pace.
Check that your expected counts add to the total sample size, your df matches the number of categories minus 1, and your chi-square total uses every category once. A quick 3-category example should always give df = 2, so that check catches a lot of errors fast.
Final Thoughts on Chi Square Goodness Of Fit
Chi-square goodness-of-fit problems look scary only until you run the same 5-step pattern a few times. Start with the claim. Convert percentages into expected counts. Compute each category’s contribution with (O-E)^2/E. Add them. Then compare the result with df = categories - 1 and a p-value or critical value. A good answer never hides behind math jargon. It says whether the sample matches the claim, names the 0.05 cutoff if your class uses it, and explains the result in plain English. That part matters more than people admit. A p-value of 0.41 and a p-value of 0.01 tell very different stories, even when the formula looks the same on paper. The mistakes also stay predictable. Students forget to turn percentages into counts. They round too early. They skip the expected-count check and then wonder why the test feels messy. Those errors cost more than a missing minus sign. They can flip the whole conclusion. Treat every chi-square problem like a small audit. Check the claim. Check the totals. Check the category count. Then write one clean sentence about the context, whether that context involves survey choices, dice, inventory, or something else with 3, 4, or 6 categories. Once you get the rhythm, the test stops looking like a puzzle and starts looking like a script you can run on purpose.
The way this actually clicks
Skip step 3 and the whole thing is wasted.
Ready to Earn College Credit?
ACE & NCCRS approved · Self-paced · Transfer to colleges · $250/course or $99/month