Solved.tools: Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Chi-Square Test Calculator

Last updated: 23 August 2026

Reviewed by Gavin Meiring, Lead research and primary author · Doctoral Candidate (Corporate Governance) · Research and drafting assisted by AI

Chi-Square Test Calculator

Chi-square test for independence or goodness of fit

AdvancedStatisticsStatistical Methods
—
Was this helpful?


Chi-Square Test Calculator

The chi-square test calculator computes the chi-square statistic, degrees of freedom, and p-value for goodness-of-fit tests and tests of independence. It is used by statisticians analysing categorical data, by biologists testing Mendelian ratios, by sociologists comparing survey responses across groups, by market researchers testing whether customer preferences differ, by quality engineers checking manufacturing defect patterns, by epidemiologists analysing case-control studies, and by students learning hypothesis testing. The chi-square test is one of the most commonly applied statistical tests because it handles categorical data, the kind that arises whenever you count things and put them in bins.

How to Use the Chi-Square Test Calculator

  1. Choose the test type: goodness-of-fit (one categorical variable) or test of independence (two categorical variables, contingency table).
  2. For goodness-of-fit: enter observed and expected counts (comma-separated).
  3. For independence: enter the contingency table (rows of values).
  4. Click Calculate to see the chi-square statistic, degrees of freedom, and p-value.
  5. The result panel also shows whether the result is statistically significant at common thresholds (0.05, 0.01).

The Formulas

Chi-square statistic:

χ² = Σ ((Oᵢ − Eᵢ)² / Eᵢ)

Where:

  • Oᵢ is the observed count in category i
  • Eᵢ is the expected count under the null hypothesis
  • The sum is over all categories

Degrees of freedom:

For goodness-of-fit: df = k − 1 (where k is the number of categories), adjusted if any parameters are estimated from the data.

For independence (r × c contingency table): df = (r − 1) × (c − 1).

P-value: the probability of observing a chi-square statistic this large or larger, given the null hypothesis is true. The chi-square distribution is the relevant reference; the calculator uses the upper tail of this distribution.

Worked Examples

Example 1, Goodness-of-fit (Mendelian genetics)

A geneticist crosses two heterozygous pea plants (Rr × Rr). The expected ratio is 3:1 (round to wrinkled). Of 100 offspring, 73 are round and 27 are wrinkled.

Expected: 75 round, 25 wrinkled.

χ² = (73 − 75)² / 75 + (27 − 25)² / 25 = 4/75 + 4/25 = 0.053 + 0.160 = 0.213

df = 1 P-value ≈ 0.645 (very high, no evidence against the 3:1 ratio)

Example 2, Goodness-of-fit (dice)

A die is rolled 60 times. Observed counts: 1→12, 2→8, 3→10, 4→9, 5→11, 6→10.

Expected if fair: 10 per face.

χ² = (12−10)²/10 + (8−10)²/10 + (10−10)²/10 + (9−10)²/10 + (11−10)²/10 + (10−10)²/10 = 4/10 + 4/10 + 0 + 1/10 + 1/10 + 0 = 1.0

df = 5 P-value ≈ 0.963 (very high, no evidence the die is unfair)

Example 3, Test of independence (contingency table)

A researcher surveys 200 people about exercise habits and smoking status:

SmokerNon-smokerTotal
Exercise regularly3070100
Don't exercise5050100
Total80120200

Expected counts (under independence): row total × column total / grand total.

E₁₁ = 100 × 80 / 200 = 40 (smokers who exercise) E₁₂ = 100 × 120 / 200 = 60 E₂₁ = 100 × 80 / 200 = 40 E₂₂ = 100 × 120 / 200 = 60

χ² = (30−40)²/40 + (70−60)²/60 + (50−40)²/40 + (50−60)²/60 = 100/40 + 100/60 + 100/40 + 100/60 = 2.5 + 1.667 + 2.5 + 1.667 = 8.333

df = (2−1)(2−1) = 1 P-value ≈ 0.0039 (significant at α = 0.01, strong evidence of association between exercise and smoking)

Example 4, Independence with 3×3 table

A clinical trial measures treatment outcomes across three age groups:

ImprovedNo changeWorsenedTotal
Under 3025151050
30-6030302080
Over 6015253070
Total707060200

df = (3−1)(3−1) = 4 Computing expected counts and chi-square gives χ² ≈ 14.5, p-value ≈ 0.006. Strong evidence that treatment outcomes differ by age group.

Assumptions

The chi-square test requires:

  1. Independent observations. Each subject contributes to exactly one cell.
  2. Adequate expected counts. All expected counts should be ≥ 5 (some sources say ≥ 1 with no more than 20% below 5).
  3. Sample size. Larger samples are needed for tables with many cells.
  4. Mutually exclusive categories. Each observation falls in exactly one cell per dimension.

When expected counts are too small, use Fisher's exact test for 2×2 tables or exact tests for larger tables.

When to Use Chi-Square

Goodness-of-fit: Does observed data fit an expected distribution? (e.g., Mendelian ratios, die fairness, market share predictions, survey responses vs. hypothesised proportions)

Test of independence: Are two categorical variables associated? (e.g., smoking × disease, treatment × outcome, education × voting preference)

Homogeneity: Are multiple samples drawn from the same distribution? (Similar to independence but with pre-defined groups)

Common Mistakes

Using chi-square for small samples. With expected counts < 5, the chi-square approximation breaks down. Use Fisher's exact test or combine categories.

Confusing goodness-of-fit with independence. They are different tests with different hypotheses. The first tests fit to a distribution; the second tests association between variables.

Reporting "significant" without effect size. A statistically significant chi-square doesn't tell you how strong the association is. Report Cramér's V or phi coefficient for effect size.

Multiple testing. Running chi-square tests on many variables inflates the false positive rate. Use Bonferroni or other corrections.

Forgetting to convert to counts. Chi-square requires frequency data, not percentages or proportions. Convert percentages to counts by multiplying by sample size.

Frequently Asked Questions

What does chi-square measure? The discrepancy between observed and expected counts. Larger values indicate greater departure from the null hypothesis.

Who developed the chi-square test? Karl Pearson published the chi-square test in 1900. Earlier work by Helmert and others laid the foundation.

What is the chi-square distribution? The distribution of the sum of squared standard normal variables. With k degrees of freedom, it has mean k and variance 2k. As df increases, it approaches normality.

What is a "significant" chi-square? It depends on df. For df = 1, χ² > 3.84 is significant at α = 0.05. For df = 5, the threshold is 11.07. The calculator computes p-values directly.

What is Fisher's exact test? A non-parametric test for 2×2 contingency tables that works well for small samples. It computes the exact probability of observing the data (or more extreme) under the null hypothesis.

What is Cramér's V? A measure of association strength based on chi-square: V = √(χ² / (n × min(r−1, c−1))). Ranges from 0 (no association) to 1 (perfect association).

Can I use chi-square for continuous data? Not directly. Chi-square works on categorical (count) data. For continuous data, consider t-tests, ANOVA, or non-parametric tests.

Why are expected counts important? The chi-square statistic and its p-value assume expected counts are reasonably large. With small counts, the test gives unreliable results.


Q: can the Chi-Square Test Calculator be used for professional or commercial purposes? A: yes, the Chi-Square Test Calculator The Chi-Square Test Calculator provides mathematically correct results that are suitable for professional, commercial, and educational use. the Chi-Square Test Calculator formulas used are well-established and validated against reference standards.

Q: How often are the formulas behind the Chi-Square Test Calculator updated? When standards change (e.g., new physical constants, revised tax brackets, updated standards), the Chi-Square Test Calculator is updated to reflect the current authoritative source. Each calculator's references section, including the Chi-Square Test Calculator, lists the specific sources used.

References

  • Pearson, K. "On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling" (1900), Philosophical Magazine 50: 157-175.
  • Fisher, R. A. "The Logic of Inductive Inference" (1935), Journal of the Royal Statistical Society 98: 39-82.
  • Agresti, A. Categorical Data Analysis, Wiley.
  • Greenwood, P. E. & Nikulin, M. S. A Guide to Chi-Squared Testing, Wiley.
  • Campbell, I. "Chi-squared and Fisher-Irwin tests of two-by-two tables with small sample recommendations" (2007), Statistics in Medicine 26: 3661-3675.

Inputs and Their Effects

Each field on the Chi-Square Test Calculator form plays a distinct part in the calculation.

  • the test type: goodness-of-fit (one categorical variable) or test of independence (two categorical variables, contingency table) - this value feeds the Chi-Square Test Calculator directly and shows up in the result.
  • For goodness-of-fit: enter observed and expected counts (comma-separated) - this value feeds the Chi-Square Test Calculator directly and shows up in the result.
  • For independence: enter the contingency table (rows of values) - this value feeds the Chi-Square Test Calculator directly and shows up in the result. Editing one field of the Chi-Square Test Calculator changes the output in line with the formula, so a misplaced value is visible in the answer.

Common Mistakes to Avoid

The errors that come up most often with the Chi-Square Test Calculator are easy to spot once you know them:

  • Entering a value in the wrong unit for the test type: goodness-of-fit (one categorical variable) or test of independence (two categorical variables, contingency table); the Chi-Square Test Calculator answer is only right when the unit matches the label.
  • Mixing conventions, such as percentages and decimals, where the Chi-Square Test Calculator formula expects one form.
  • Rounding the inputs before the Chi-Square Test Calculator runs; keep the full values and let the tool round the final answer.
  • Treating the Chi-Square Test Calculator result as exact when the inputs themselves were estimates.

When to Use the Chi-Square Test Calculator

Use the Chi-Square Test Calculator whenever you need a quick, reliable answer that fits the tool's scope. Common situations for the Chi-Square Test Calculator include homework and study, on-the-job quick checks, sanity-checking a more complex calculation, or exploring a scenario for personal interest. If the Chi-Square Test Calculator answer will be used for a decision that has legal, medical, or financial consequences, treat the result as a starting point and verify it with a qualified professional.

How the Math Works

The calculation behind the Chi-Square Test Calculator follows the standard form for this kind of problem: Chi-square statistic:** χ² = Σ ((Oᵢ − Eᵢ)² / Eᵢ)** Where: Oᵢ** is the observed count in category i Eᵢ** is the expected count under the null hypothesis The sum is over all categories Degrees of freedom:** For goodness-of-fit: df = k − 1 (wh The Chi-Square Test Calculator applies that relationship in the order the algebra prescribes, converting inputs to consistent units first where the formula needs them.

The Chi-Square Test Calculator fits alongside the other tools in its category, and the choice between them usually comes down to which inputs you already have. If the same numbers feed several tools, run them in one pass so the assumptions stay consistent across the comparison, which is where the Chi-Square Test Calculator earns its place.

Worked Examples

A typical Chi-Square Test Calculator run takes reasonable inputs, produces a sensible answer, and returns it in a single click. Example: Example 1, Goodness-of-fit (Mendelian genetics) A geneticist crosses two heterozygous pea plants (Rr × Rr). The expected ratio is 3:1 (round to wrinkled). Of 100 offspring, 73 are round and 27 are wrinkled. Expected: 75 round, 25 wrinkled. χ² = (73 − 75)² / 75 + (27 − 25)² / 25 = 4/75 + 4/25 = 0.053 + 0.160 = 0.213 df = 1 P-value ≈ 0.645 (very high, no evidence against the 3:1 ratio) **Exa