On this page
When a goodness-of-fit test fits
A Pearson chi-square goodness-of-fit test compares counts from one categorical variable with probabilities specified by a model or a justified reference distribution. Under the null hypothesis, each independent observation falls into exactly one of the mutually exclusive, exhaustive categories, with the stated probability for that category. The test asks whether the observed frequencies depart from those expected under that model.
This is different from a chi-square test of independence. Goodness-of-fit starts with one categorical variable and a specified distribution; independence starts with two variables and estimates expected cell counts from the table margins. Choose from the question and sampling design before entering counts.
Enter category counts and expected probabilities
Enter one category per row, with three tab-separated fields: its label, observed count and expected probability. Probabilities must be greater than zero and no greater than one, and they must add to 1. Use probabilities that were specified independently of the observed counts. The calculator does not infer missing categories, rescale probabilities or estimate model parameters.
The built-in example is constructed. It records 20, 16 and 14 observations for three mutually exclusive options and compares them with probabilities 0.50, 0.30 and 0.20 specified in advance. Replace those values with counts and a distribution justified by your study or assignment; do not enter percentages in the count column.
How expected counts, χ² and degrees of freedom are calculated
For category i, the expected count is Eᵢ = Npᵢ, where N is the total observed count and pᵢ is its specified probability. Pearson’s statistic sums (Oᵢ − Eᵢ)²/Eᵢ across categories. With k categories and no distribution parameters estimated from these same observations, the reference degrees of freedom are k − 1, and the p-value is the upper-tail probability from that chi-square distribution.
The table also shows the Pearson residual (Oᵢ − Eᵢ)/√Eᵢ and each category’s contribution to the statistic. A larger absolute residual marks a larger descriptive departure for that category; it is not a post-hoc significance test and does not by itself establish which categories differ after accounting for multiple comparisons.
Check expected counts and how the probabilities were chosen
The chi-square p-value uses an approximation. Small expected frequencies can make that approximation unreliable; a common diagnostic guideline is to review categories with expected counts below five, but it is not a universal pass/fail rule. This tool flags those counts and does not merge categories or switch methods automatically. Depending on the design and question, a suitable exact multinomial or simulation-based method may be needed.
The k − 1 degrees of freedom apply when the probabilities are fully specified independently of the observed sample. If you estimated one or more distribution parameters from these same counts, the reference degrees of freedom may need adjustment, and the asymptotic distribution may require a different justification. This calculator does not support fitted parameters, weighted observations, dependent cases, structural-zero categories or continuous-distribution goodness-of-fit tests.
Interpret the result without overstating it
A small p-value says that counts this far or farther from the specified distribution would be unusual under the null model and test assumptions. It does not measure how plausible the model is, show that a category causes an outcome or establish practical importance. Compare the observed counts, expected counts and residuals, then explain why the reference probabilities make sense for the research question.
This browser tool computes a Pearson statistic for one fully specified categorical distribution. It does not inspect individual records, assess the sampling process, determine whether categories were defined before analysis, select a null distribution or verify that the data are independent. Follow your course or study plan and ask for methods advice when those conditions are unclear.
Free categorical-data calculator
Compare observed counts with a specified distribution
Enter one category per row, with a label, observed whole-number count and expected probability. Probabilities must add to 1.
Option A 20 0.50 Option B 16 0.30 Option C 14 0.20
50 observations compared with probabilities specified in advance.Your counts and probabilities stay in this browser tab. Enter aggregated counts only; do not include names, IDs or confidential records.
The constructed example has 3 categories and 50 observations. Calculate to compare expected and observed counts.
Goodness-of-fit test summary
Pearson χ² statistic
Degrees of freedom
Upper-tail p-value
Observed cases
Smallest expected count
| Category | Observed | Expected | χ² contribution | Pearson residual |
|---|
Residuals describe category departures; they are not separate significance tests.
Questions about this topic
What is the null hypothesis for a chi-square goodness-of-fit test?
The null hypothesis is that observations follow the specified category probabilities. The test compares observed counts with expected counts under that distribution, assuming independent observations and a suitable chi-square approximation.
How do I calculate expected counts?
Multiply the total number of observations by each category’s expected probability: Eᵢ = Npᵢ. The probabilities must describe a complete distribution and sum to 1.
How many degrees of freedom does the test have?
For k categories and probabilities specified independently of the sample, degrees of freedom are k − 1. If distribution parameters were estimated from the same observations, a correction or different reference distribution may be needed; this tool does not calculate that case.
What if an expected count is below five?
A small expected count can make the chi-square approximation unreliable. Review the study design and consider a suitable exact or simulation-based method. Five is a diagnostic guideline, not an automatic threshold for merging categories.
Is this the same as a chi-square test of independence?
No. Goodness-of-fit tests one categorical variable against specified probabilities. A test of independence examines association between two categorical variables and derives expected cell counts from table margins.
Are my counts uploaded?
No. The calculation runs in this browser tab. The tool does not send the entered category counts or probabilities to AI Essay.
Sources and editorial notes
The supporting reading below informs our editorial guidance. Exercises and scenarios illustrate a method; they do not report a completed product test or measured learning outcome. Read our editorial policy or send a correction with a supporting source to info@ai-essay.com.