AP Stats Chi-Square Calculator
Test whether observed counts match the counts you would expect under a claimed distribution. Enter your observed and expected counts below, and this goodness-of-fit calculator will compute the chi-square statistic, degrees of freedom, and each category's contribution.
Chi-Square Goodness-of-Fit Calculator
Comma-separated counts, one per category.
Comma-separated counts of the same length as the observed list. Every expected count must be greater than 0.
Results
Chi-square statistic (χ²): —
Degrees of freedom (df): —
Number of categories: —
Interpretation guidance
A larger chi-square statistic means the observed counts differ more from the expected counts. A small statistic means the observed counts are close to what the claimed distribution predicts.
For the chi-square approximation to be trustworthy, expected counts should generally be at least 5 in each category. If several expected counts are below 5, be cautious about the conclusion and consider combining categories when it makes sense in context.
This page does not report an exact p-value. On an AP Statistics exam, compare your statistic to a chi-square critical value (or use the chi-square CDF on your calculator) for the degrees of freedom above, and state your conclusion in context.
Interactive visual: Live preview
Press Show live preview to redraw this chart from your calculator inputs.
What Is a Chi-Square Test?
A chi-square test compares the counts you observed in categories with the counts you would expect if a claim were true. It is used for goodness of fit, does this distribution match the claimed one, and for tests of independence and homogeneity with two categorical variables. Large differences between observed and expected counts give a large chi-square statistic and a small p-value.
Interactive visual: See the idea
Example: observed 32, 28, 25, 15 vs expected 25 each.
How to Use This Calculator
Interactive visual: Walk through it
Step 1: Open the AP Stats Chi-Square Calculator calculator at the top and enter the values it asks for.
- List your categories in the same order for both inputs — for example, four colors, four days, or four answer choices.
- Type the observed counts you actually collected, separated by commas.
- Type the expected counts under the claimed distribution, separated by commas. If the claim is "equally likely," divide the total by the number of categories.
- Click Calculate Chi-Square and read the statistic, degrees of freedom, and contribution table.
- Compare the statistic to a chi-square critical value for your degrees of freedom, or find the p-value with a chi-square CDF, before writing your conclusion.
How to Calculate Chi-Square
Interactive visual: See it on a chart
Press Update visual to redraw this chart from your calculator inputs.
For a goodness-of-fit test, the chi-square statistic is:
χ² = Σ (Observed − Expected)² / Expected
Degrees of freedom are:
df = number of categories − 1
Worked example
Suppose 100 students are asked to pick a favorite color, and the claim is that the four colors are equally popular. You observe 32, 28, 25, and 15. The expected count for each color is 100 ÷ 4 = 25.
χ² = (32−25)²/25 + (28−25)²/25 + (25−25)²/25 + (15−25)²/25
= 49/25 + 9/25 + 0/25 + 100/25
= 1.96 + 0.36 + 0 + 4.00 = 6.32
With 4 categories, df = 4 − 1 = 3. The largest contribution (4.00) comes from the last category, where 15 observed is well below the expected 25.
Tips and Common Mistakes
Interactive visual: Mistake vs correct
Mistake: Using observed counts as expected counts.
- Use counts, not percentages or proportions. Chi-square goodness-of-fit uses raw frequencies; entering 0.32 instead of 32 will give a wrong statistic.
- Keep the order identical in the observed and expected lists, or categories will be paired incorrectly.
- Check the expected-count condition. Expected counts should generally be at least 5. Small expected counts make the chi-square approximation unreliable.
- Do not confuse the statistic with a p-value. A chi-square value of 6.32 is not a probability — it must be compared to the chi-square distribution for the right degrees of freedom.
- Use the correct degrees of freedom. For goodness of fit it is categories minus 1, not the sample size minus 1.
- State conclusions in context. Say whether the data provide convincing evidence against the claimed distribution, and name the distribution or claim you tested.
- Check your total. The expected counts should add up to (approximately) the same total as the observed counts.
Frequently Asked Questions
Interactive visual: FAQ
Tap any question below to show or hide its answer.
What is the difference between goodness of fit, independence, and homogeneity?
Goodness of fit compares one categorical variable to a claimed distribution. Independence tests whether two categorical variables are associated within a single sample. Homogeneity tests whether the distribution of one categorical variable is the same across two or more populations or groups. This page is for goodness of fit only.
How do I find the degrees of freedom for a chi-square goodness-of-fit test?
Subtract 1 from the number of categories: df = categories − 1. For example, a test with 5 categories has 4 degrees of freedom.
Why must expected counts generally be at least 5?
The chi-square test relies on an approximation to the chi-square distribution. When expected counts are very small, that approximation can be poor, so the resulting conclusion may be misleading. If this condition fails, consider combining sensible categories or using another method.
What does a large chi-square statistic mean?
It means the observed counts are far from the expected counts in at least one category. Check the per-category contribution table to see which categories drive the difference — the largest (O−E)²/E values matter most.
Can I use this calculator with percentages?
No. Convert percentages back to counts first, using the sample size. For example, 32% of 100 people is 32 people. Entering percentages directly will understate the statistic.
What are the conditions for a chi-square goodness-of-fit test?
The data should come from a random sample or randomized experiment, the observations should be counts of a categorical variable, and all expected counts should generally be at least 5. Also verify that no individual is counted in more than one category.
Does a small chi-square statistic prove the claimed distribution is true?
No. A small statistic means the data are consistent with the claim, but it does not prove the claim. In AP Statistics language, you fail to reject the null hypothesis — you do not accept it as proven.
Disclaimer: AP is a trademark of the College Board, which was not involved in the production of, and does not endorse, this site.
Related Calculators and Guides
Keep exploring AP Statistics with calculators and guides related to this tool.
Related Calculators
Interactive visual: Tool path
Start with this tool, then follow the path through the related calculators.
Chi-Square Calculator → Hypothesis Testing Calculator → P-Value Calculator