Chi-Square Sum Calculator

Σ(O − E)²/E for goodness of fit or a contingency table, with df, p-value and critical value.

  1. Enter valuesUse your own inputs or an example
  2. CalculateApply your selected settings
  3. View resultExplore the answer and explanation

Enter the counts

Enter your values below to get started.

Examples:
Test
1 count per category, separated by spaces, commas or new lines.
Leave blank for equal proportions.
Subtracted from df, for example 1 when you estimate a Poisson mean.
1 row per line, columns separated by spaces or commas.
Reset restores the default values.

Tips for this calculator

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.

What Is a Chi-Square Sum?

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.

χ2=∑i=1k(Oi−Ei)2Ei\chi^2 = \sum_{i=1}^{k} \frac{(O_i - E_i)^2}{E_i}

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.

InteractiveRoll counts for a die: is it fair?

How Does the Chi-Square Sum Calculator Work?

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).

InteractiveEach class's (O − E)²/E stacks into χ²
  1. Expected counts

    Ratios are scaled to the total: 9 : 3 : 3 : 1 of 556 plants gives 312.75, 104.25, 104.25 and 34.75.

  2. Cell contributions

    (315 − 312.75)²/312.75 = 0.0162, and so on for each category.

  3. Sum

    χ² = 0.0162 + 0.1349 + 0.1013 + 0.2176 = 0.4700.

  4. df and p-value

    df = 4 − 1 = 3; p = P(χ²₃ > 0.47) = 0.9254, a close fit.

Chi-Square Sum Formula

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.

Chi-Square Statistic

χ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E}

Expected Counts

Ei=NpiEij=Ri CjNE_i = N p_i \qquad E_{ij} = \frac{R_i\,C_j}{N}

pi is the expected proportion; Ri and Cj are row and column totals.

Degrees of Freedom

dffit=k−1−mdftable=(r−1)(c−1)df_{\text{fit}} = k - 1 - m \qquad df_{\text{table}} = (r-1)(c-1)

m is the number of parameters estimated from the data.

Yates Correction for 2 × 2 Tables

χYates2=∑(∣O−E∣−0.5)2E\chi^2_{\text{Yates}} = \sum \frac{(|O - E| - 0.5)^2}{E}
Interactive1 cell's term (O − E)²/E as O moves

Types of Chi-Square Tests

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.

InteractiveWhere E comes from in each type of test

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.

Test of independence

2 categorical variables measured on 1 sample, such as smoking and exercise. df = (r − 1)(c − 1).

Test of homogeneity

1 variable compared across separately sampled groups, such as product sizes bought in 2 stores. Same arithmetic as independence.

How to Calculate a Chi-Square Sum by Hand

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.

  1. Row totals 50 and 50; column totals 45 and 55; N = 100.
  2. Expected: 50 × 45 / 100 = 22.5 and 27.5 in each row.
  3. Contributions: (30 − 22.5)²/22.5 = 2.5; (20 − 27.5)²/27.5 = 2.0455; (15 − 22.5)²/22.5 = 2.5; (35 − 27.5)²/27.5 = 2.0455.
  4. χ² = 2.5 + 2.0455 + 2.5 + 2.0455 = 9.0909.
  5. df = (2 − 1)(2 − 1) = 1; p = 0.0026 < 0.05, so the variables are associated.
InteractiveStep through 2 chi-square sums

    Chi-Square p-Value and Critical Value

    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 < α.

    • df = 1: critical value 3.8415 at α = 0.05 and 6.6349 at α = 0.01.
    • df = 2: 5.9915 at α = 0.05.
    • df = 3: 7.8147 at α = 0.05.
    • df = 5: 11.0705 at α = 0.05.

    The chi-square distribution with df degrees of freedom has a mean of df and a variance of 2·df.

    InteractiveMove χ² and df: the shaded tail is the p-value

    Degrees of Freedom in a Chi-Square Test

    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.

    InteractiveFree and fixed cells in an r × c table

    Common Mistakes with Chi-Square Sums

    • Using percentages as observed counts: χ² depends on sample size, so use the raw counts.
    • Expected counts below 5: merge categories or use Fisher's exact test for small 2 × 2 tables.
    • Dividing by O instead of E: the denominator is the expected count.
    • Wrong df: a 2 × 3 table has (2 − 1)(3 − 1) = 2 df, not 5.
    • Expected counts that do not add up to N: the observed and expected totals must match.
    InteractiveTrue or false: chi-square sums
    1. χ² can be negative when observed counts are below expected.

    2. A 3 × 4 contingency table has 6 degrees of freedom.

    3. A larger χ² gives a larger p-value.

    4. The expected count for a cell is row total × column total ÷ N.

    5. Observed percentages can replace observed counts in Σ(O − E)²/E.

    Score: 0 / 5

    How to Use the Chi-Square Sum Calculator

    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.

    InteractiveLoad a ready-made chi-square problem

    Each button fills the calculator and runs it.

    1. Choose the test

      Goodness of fit for 1 variable, contingency table for 2 variables.

    2. Enter observed counts

      315 108 101 32, or a table with 1 row per line.

    3. Enter expected values

      Ratios like 9 3 3 1, expected counts, or blank for equal shares.

    4. Read the decision

      p < α rejects H₀; the table tab shows which cells drive χ².

    Real-Life Applications of Chi-Square Sums

    Chi-square sums test whether counted outcomes match a theory or whether 2 categories are linked. There are 5 common applications:

    • Genetics: Gregor Mendel's pea counts (315, 108, 101, 32) fit the 9 : 3 : 3 : 1 ratio with χ² = 0.47.
    • Quality control: defect counts by shift or machine compared with equal shares.
    • Marketing: survey answers by age group tested for independence.
    • Medicine: treatment vs. outcome in a 2 × 2 table.
    • Gaming and lotteries: dice, roulette and lottery draws tested for fairness.
    Interactive3 real goodness-of-fit data sets

    Chi-Square Sum Examples

    7 goodness-of-fit and contingency table calculations at α = 0.05.

    Chi-Square Sum Examples
    Dataχ²dfp-valueDecisionCalculator
    Mendel 315, 108, 101, 32 vs. 9:3:3:10.470030.9254Good fit
    Die: 8, 12, 9, 11, 6, 144.250.5210Fair
    Coin: 58 heads, 42 tails2.5610.1096Fair
    Calls: 52, 41, 38, 45, 648.958340.0622Not significant
    Table 30, 20 / 15, 359.090910.0026Associated
    Table 12, 18, 20 / 28, 22, 109.301120.0096Associated
    Table 40, 35, 25 / 25, 45, 305.166120.0755Not significant

    Popular Chi-Square Sum Problems

    Try each one, then reveal the answer or solve it in the calculator.

    1. A coin shows 58 heads and 42 tails in 100 flips. Find χ² and the p-value.

      Show answer\chi^2 = 2.56,\ p = 0.1096
    2. Mendel counted 315, 108, 101 and 32 peas. Test the fit to 9 : 3 : 3 : 1.

      Show answer\chi^2 = 0.4700,\ df = 3,\ p = 0.9254
    3. Observed 48, 35, 17 against expected counts 40, 40, 20. Find χ².

      Show answer\chi^2 = 2.675,\ p = 0.2625
    4. Find χ² for the 2 × 2 table 30, 20 / 15, 35 and decide at α = 0.05.

      Show answer\chi^2 = 9.0909,\ p = 0.0026,\ \text{reject } H_0
    5. Test independence in the 2 × 3 table 20, 30, 50 / 30, 40, 30.

      Show answer\chi^2 = 8.4286,\ df = 2,\ p = 0.0148
    6. Apply the Yates correction to the 2 × 2 table 10, 20 / 20, 10.

      Show answer\chi^2_{\text{Yates}} = 5.4,\ p = 0.0201

    Explore More Sum Calculators

    Discover 67 free sum calculators across different categories. Find the right calculator for your needs.

    Browse All 67 Calculators
    Questions and answers

    Frequently Asked Questions

    What is a chi-square sum calculator?

    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.

    How do you calculate the chi-square statistic?

    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.

    How do you find expected counts in a contingency table?

    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.

    What are the degrees of freedom for a chi-square test?

    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.

    What does a large chi-square value mean?

    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₀.

    Can the chi-square statistic be negative?

    No, the chi-square statistic cannot be negative, since every term (O − E)²/E is a square divided by a positive number.

    When should you use the Yates correction?

    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.

    What if an expected count is below 5?

    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.

    Is the chi-square test the same as the chi-square sum?

    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.

    Conclusion

    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.

    InteractiveWhich chi-square test do you need?