Goodness of fit
1 categorical variable against claimed proportions, such as a fair die or a 9 : 3 : 3 : 1 genetic ratio. df = k − 1.
Σ(O − E)²/E for goodness of fit or a contingency table, with df, p-value and critical value.
Enter your values below to get started.
Use raw counts, not percentages, for the observed values.
Every expected count should be at least 5 for the p-value to be reliable.
Ratios such as 9 3 3 1 or percentages such as 45 40 11 4 are scaled to your total.
Contingency tables compute E = row total × column total ÷ N automatically.
A chi-square sum calculator adds (O − E)²/E over every category or table cell to get the chi-square statistic χ², then turns χ² into a p-value. Enter observed counts with expected counts or ratios for a goodness-of-fit test, or paste a contingency table for a test of independence, and get χ², the degrees of freedom, the p-value, the critical value, each cell's contribution and the chi-square curve.
A chi-square sum is the statistic χ² = Σ(O − E)²/E, which adds the squared gaps between observed counts O and expected counts E, each scaled by E. Karl Pearson introduced the statistic in 1900 to test whether counted data fit a theory.
A χ² of 0 means the counts match the expectation exactly; larger values mean a worse fit. 60 rolls of a die showing 8, 12, 9, 11, 6 and 14 against 10 per face give χ² = 4.2 with 5 degrees of freedom (df), p = 0.521, which is consistent with a fair die.
The chi-square sum calculator computes the expected count for every category or cell, adds each (O − E)²/E and compares the total with the chi-square distribution. The p-value comes from the regularized incomplete gamma function, P(χ² > x) = Q(df/2, x/2).
Ratios are scaled to the total: 9 : 3 : 3 : 1 of 556 plants gives 312.75, 104.25, 104.25 and 34.75.
(315 − 312.75)²/312.75 = 0.0162, and so on for each category.
χ² = 0.0162 + 0.1349 + 0.1013 + 0.2176 = 0.4700.
df = 4 − 1 = 3; p = P(χ²₃ > 0.47) = 0.9254, a close fit.
The chi-square sum formula is χ² = Σ(O − E)²/E, summed over all categories or table cells. 3 more formulas give the expected counts, the degrees of freedom and the Yates-corrected sum.
pi is the expected proportion; Ri and Cj are row and column totals.
m is the number of parameters estimated from the data.
There are 3 types of chi-square tests that use the chi-square sum: goodness of fit, independence and homogeneity. All 3 compute Σ(O − E)²/E; they differ in where E comes from and in the question asked.
1 categorical variable against claimed proportions, such as a fair die or a 9 : 3 : 3 : 1 genetic ratio. df = k − 1.
2 categorical variables measured on 1 sample, such as smoking and exercise. df = (r − 1)(c − 1).
1 variable compared across separately sampled groups, such as product sizes bought in 2 stores. Same arithmetic as independence.
To calculate a chi-square sum by hand, find each expected count, subtract it from the observed count, square the difference, divide by the expected count and add the results. Here is a 2 × 2 table: 30, 20 in row 1 and 15, 35 in row 2.
The p-value is the area under the chi-square curve to the right of your χ², and the critical value is the χ² that leaves exactly α in that tail. Reject H₀ when χ² exceeds the critical value, which is the same as p < α.
The chi-square distribution with df degrees of freedom has a mean of df and a variance of 2·df.
The degrees of freedom count how many cells can vary freely once the totals are fixed: k − 1 for a goodness-of-fit test and (r − 1)(c − 1) for a contingency table. A 3 × 4 table has (3 − 1)(4 − 1) = 6 degrees of freedom.
Subtract 1 more degree of freedom for each parameter estimated from the data; testing a Poisson fit with 6 categories and an estimated mean gives df = 6 − 1 − 1 = 4.
Pick goodness of fit or contingency table, paste the counts and press Calculate. The result shows χ², df, the p-value, the critical value, each cell's contribution in a table and the chi-square curve.
Goodness of fit for 1 variable, contingency table for 2 variables.
315 108 101 32, or a table with 1 row per line.
Ratios like 9 3 3 1, expected counts, or blank for equal shares.
p < α rejects H₀; the table tab shows which cells drive χ².
Chi-square sums test whether counted outcomes match a theory or whether 2 categories are linked. There are 5 common applications:
7 goodness-of-fit and contingency table calculations at α = 0.05.
| Data | χ² | df | p-value | Decision | Calculator |
|---|---|---|---|---|---|
| Mendel 315, 108, 101, 32 vs. 9:3:3:1 | 0.4700 | 3 | 0.9254 | Good fit | |
| Die: 8, 12, 9, 11, 6, 14 | 4.2 | 5 | 0.5210 | Fair | |
| Coin: 58 heads, 42 tails | 2.56 | 1 | 0.1096 | Fair | |
| Calls: 52, 41, 38, 45, 64 | 8.9583 | 4 | 0.0622 | Not significant | |
| Table 30, 20 / 15, 35 | 9.0909 | 1 | 0.0026 | Associated | |
| Table 12, 18, 20 / 28, 22, 10 | 9.3011 | 2 | 0.0096 | Associated | |
| Table 40, 35, 25 / 25, 45, 30 | 5.1661 | 2 | 0.0755 | Not significant |
Try each one, then reveal the answer or solve it in the calculator.
A coin shows 58 heads and 42 tails in 100 flips. Find χ² and the p-value.
Mendel counted 315, 108, 101 and 32 peas. Test the fit to 9 : 3 : 3 : 1.
Observed 48, 35, 17 against expected counts 40, 40, 20. Find χ².
Find χ² for the 2 × 2 table 30, 20 / 15, 35 and decide at α = 0.05.
Test independence in the 2 × 3 table 20, 30, 50 / 30, 40, 30.
Apply the Yates correction to the 2 × 2 table 10, 20 / 20, 10.
Discover 67 free sum calculators across different categories. Find the right calculator for your needs.
Try a different name or choose another category.
A chi-square sum calculator is an online tool that adds (O − E)²/E over every category or table cell to get the chi-square statistic. It returns the degrees of freedom, the p-value and the critical value for a goodness-of-fit test or a test of independence.
Subtract each expected count from the observed count, square the difference, divide by the expected count and add the results: χ² = Σ(O − E)²/E. For 58 heads and 42 tails against 50 each, χ² = 1.28 + 1.28 = 2.56.
Multiply the row total by the column total and divide by the grand total: E = R × C ÷ N. In a table with row total 50, column total 45 and N = 100, E = 22.5.
The degrees of freedom are k − 1 for a goodness-of-fit test with k categories and (r − 1)(c − 1) for a contingency table with r rows and c columns.
A large chi-square value means the observed counts are far from the expected counts, which gives a small p-value and evidence against H₀.
No, the chi-square statistic cannot be negative, since every term (O − E)²/E is a square divided by a positive number.
Use the Yates correction for 2 × 2 tables with small expected counts; it subtracts 0.5 from each |O − E| before squaring. With large samples, the correction changes little and many statisticians skip it.
Combine small categories or use Fisher's exact test for a 2 × 2 table. The chi-square approximation becomes unreliable when more than 20% of expected counts are below 5.
No, the chi-square sum is the statistic Σ(O − E)²/E, while the chi-square test compares that statistic with the chi-square distribution to get a p-value and a decision.
The chi-square sum χ² = Σ(O − E)²/E measures how far counted data are from an expectation, and the chi-square sum calculator returns χ², the degrees of freedom, the p-value and the critical value for goodness-of-fit and contingency table tests. Use raw counts, keep expected counts at 5 or more, and read the cell contributions to see where the difference comes from.
Not sure which chi-square test fits? Answer the questions below.