Chi-Square Goodness of Fit Calculator

Chi-Square Goodness of Fit Calculator

Test whether observed category counts match a hypothesized distribution. Enter counts and expected proportions, then review expected counts, chi-square contributions, degrees of freedom, and the right-tail p-value from the chi-square CDF.

🎯Goodness-of-Fit Presets

📝Test Inputs

Comma-separated labels. The calculator matches labels, observed counts, and hypothesized values by position.

Use frequencies only. Commas, tabs, spaces, or line breaks are accepted.

Enter proportions, percentages, ratios, or expected counts; values are normalized to proportions.

Use 0 for a fully specified distribution; subtract fitted parameters from df.

Chi-square statistic 0.000 sum of all cell contributions
P-value 0.0000 right-tail chi-square probability
Degrees of freedom 0 k - 1 - estimated parameters
Decision -- compared with alpha

🔢Current Test Snapshot

100Total n
6Categories
16.67Min expected
--Top driver

📊Observed vs Expected Breakdown

CategoryObservedHypothesized pExpectedO - E(O - E)^2 / EShare of X2
Results load when the calculator runs.

🗂Goodness-of-Fit Method Comparison

MethodInput dataExpected basisDegrees of freedomBest useMain caution
Pearson chi-square GOFCategory countsn times hypothesized pk - 1 - mTesting a known category distributionExpected counts should not be too small
Uniform GOFCategory countsEqual proportionsk - 1Dice, days, bins, or equally likely choicesIndependence of observations still matters
Multinomial GOFOne outcome per trialSpecified category probabilitiesk - 1 - mSurvey choices or product mix auditsApproximation improves as n grows
Distribution fit with fitted parametersBinned sample dataFitted model bin probabilitiesk - 1 - fitted mNormal, Poisson, or other model checksSubtract every estimated model parameter
Exact multinomial testSmall category countsSpecified probabilitiesNot chi-square df basedVery small samples with sparse expected cellsMore computationally intensive
Chi-square independenceTwo-way count tableRow total times column total / n(r - 1)(c - 1)Association between two categorical variablesDifferent question than one-sample GOF

📋Degrees of Freedom Examples

ScenarioCategories kEstimated parameters mdf formuladfWhy
Fair six-sided die606 - 1 - 05All six probabilities are specified as equal
Four answer choices, known split404 - 1 - 03No probability is fitted from the data
Poisson count bins, lambda fitted616 - 1 - 14The rate parameter consumes one df
Normal bins, mean and SD fitted828 - 1 - 25Two model parameters are estimated
Too many fitted parameters434 - 1 - 30The chi-square p-value is not defined

📑Expected Count and Evidence Checks

CheckTypical guidelinePass signalWarning signalAction
Expected cell sizeEvery expected count at least 5Approximation usually usableAny E below 5Combine defensible categories or use exact methods
Total sample sizeLarger n improves approximationStable expected countsVery small nTreat p-value as rough
IndependenceEach observation belongs to one categoryOne count per item or personRepeated or paired countsUse a model for dependent data
Hypothesis specified firstExpected proportions are not tuned after seeing OPredefined proportionsPost-hoc targetsReport how the target distribution was chosen
Significance levelAlpha chosen before testingp <= alpha rejects fitChanging alpha after resultKeep alpha fixed in the report

Formula Breakdown

Total countn = sum(Oi), where Oi is the observed count in category i.
Normalize hypothesispi = entered weight i / sum(all entered weights). Percentages, ratios, and expected-count patterns all become proportions.
Expected countEi = n × pi. This calculator uses the observed total n and the hypothesized proportion for each category.
Cell contributionContribution i = (Oi – Ei)² / Ei. Large values identify categories driving the lack of fit.
Chi-square statisticX² = sum((Oi – Ei)² / Ei) across all k categories.
Degrees of freedomdf = k – 1 – m, where m is the number of parameters estimated from the same data.
P-valuep = 1 – CDFchi-square(X², df). A smaller p-value means the observed counts are less consistent with the hypothesized distribution.

💡Practical Goodness-of-Fit Tips

Use independent counts: Each item should contribute to exactly one category. If the same person, product, or event can appear in multiple rows, a one-sample goodness-of-fit test is usually not the right structure.
Inspect contributions after the p-value: The test tells you whether the whole distribution is surprising. The contribution table shows which categories account for the chi-square statistic.

When we ask if our observations align with expectations, we are performing a chi-square goodness of fit test. For example, imagine you think a mixed color bag of candy is imbalanced with flavor. Without this tool, you are left with hunches. With it, you go from thinking something smells fishy, to having proof that’s fishy. By running your actual results against your expectations, the test provides statistical support that takes you from suspicious to confident.

No table-hunting required. No complicated formula to memorize. Just use the calculator at the top. Plug in your numbers and hypotheses. Get a decision. This is easy to understand at an intuitive level.

How to Use the Chi-Square Goodness of Fit Test

First, come up with some guess or idea as to what distribution of data will look like. Next, gather actual counts from reality and compare them to your hypothesized distribution. The test measures how much they differ. If the two are similar, then it’s reasonable to assume the data conforms to the model. If not, then it doesn’t. How do you decide when a difference is actualy significant? That is measured by how much variation we allow in any given category. One simple measure of this is called the chi-square statistic, a number that sums up overall degree of variance over all categories combined.

But you must discipline yourself to fill in the numbers. Fill in the actual count of how many items falls into each category. That’s the raw frequency, what you saw when you audited or conducted your experiment. Next, fill in the proposed probabilities. Here, again, you have options. You can fill in either exact counts or ratios or percentages of what you expect to see. The software will adjust it for you so that all those proportions add up to 100 percent. Nice, because real world hypotheses aren’t usually nice clean decimals. Maybe you think that two out of every three lights should be red? You type 2 and 1. No need to do the math to get to 0.666 and 0.333. The software fills in the gaps.

The second key parameter is number of parameters we estimate from the data. In the case of testing a die to see if it’s fair, you already have prior knowledge about the probability for every face. So you’re estimating zero parameters. But when you’re testing to see if a dataset fits a normal distribution, you often use the same set of data to find the mean and standard deviation. Each estimated parameter uses up one of the degrees of freedom. Remove that from the category count, and the test becomes more sensitive. The risk you’ll falsely accept a bad fit is lowered.

But the result isn’t just a yes/no answer. Instead, it returns a p-value: how likely you are to see this much difference if your assumption about reality (the hypothesis) is true. If the p-value is low (often considered < 0.05), it means that your observation is unlikely to occur if the model holds. Therefore, you reject the null hypothesis.

That said, the p-value by itself can be misleading. It doesn’t show you specifically what’s causing you to reject the hypothesis. You want to look at the contribution of each category. Many might have contributed substantialy to the overall statistic. These should stand out and help you understand why things don’t fit the model. Is there one particular kind of defect that’s being over-represented? Is there one option on the survey that is completely skipped?

Of course, it has its limitations. You need enough counts per category for the chi-square approximation to work well. For a given cell, that means the expected count needs to be at least 5, based off your sample size. That’s where the assumption about sufficient sample sizes fails. When the expected values fall too low (below 5), then result may not be trustworthy. In those cases, you should of use exact tests and combine sparse categories. The tool warns when such circumstances arises. And it lets you know when you’re trying to make conclusions from wobbly ground.

Another important caveat is the independence of observations. Every data point should be in exactly one category. Observations shouldn’t impact others selection.

This test takes the expectation and pits it against reality. It makes you say up front what you expect will happen before you see the results, and that helps shield you from confirmation bias. If you’re looking at whether a shuffle is random, or consumer preference, or the quality of a manufactured item, the steps stay the same: set the baseline; see how far off it is; then ask math if that distance means anything. Math does the work for you in calculating the number. You need to use your judgment to interpret what it means. Looking at both the big picture and the contribution of each category helps you understand your data better. Maybe all your candies were bad luck. Or maybe you have a system-wide problem. Using the test provides you with words to express the gap.

Chi-Square Goodness of Fit Calculator