Summary: This chi square calculator computes goodness-of-fit and independence with live steps, formulas and a chart. It accepts labeled numeric inputs, works offline through file:// and includes source-backed explanations for students, analysts and researchers.
Chi Square Calculator
Editorially reviewedReviewed by Agarapu Ramesh, science educator (chemistry). LinkedIn
Last reviewed: May 2026|Standard statistical formulas
Chi square calculator for goodness-of-fit and contingency table independence tests with p-value, df and steps. The calculator works offline, updates instantly and includes a worked example, plain-text formula, MathML, references and structured data.
Default values are loaded. Click any field and edit it; results and chart update automatically.
Default example loadedobserved 50,30,20 and expected 40,40,20. Change any value above to test your own data.
Result: -
Chi Square Calculator Quick Reference
Input or setting
Result or interpretation
Use this when
df=1, alpha=.05
critical chi-square=3.841
categorical testing
df=2, alpha=.05
critical chi-square=5.991
categorical testing
expected counts
prefer at least about 5 per cell
categorical testing
How to Use This Chi Square Calculator
Choose one calculator from the dropdown, such as Standard Deviation Calculator or Linear Regression Calculator.
Paste raw data into textarea fields or enter summary statistics in number fields.
Review the headline result, supporting metrics, step-by-step solution and SVG visualization.
Use the example button to compare against a known worked example from the reference table.
Copy the result or export the visible output as CSV or PNG for notes and reports.
Read the interpretation, pitfalls, glossary and references before making research decisions, especially when assumptions or tails affect the answer.
The chi-square statistic sums squared observed-minus-expected differences scaled by expected counts.
Example
observed 50,30,20; expected 40,40,20
chi-square=5.0; df=2; p about 0.082
This page uses the shared statistics core for distribution functions, quantiles and exact integer counting where needed. The formula is shown in plain text so screen readers and search engines can parse it reliably.
Chi Square Calculator Worked Example
Use Load example in the calculator to reproduce this reference result.
What does p = 0.03 mean? If the null hypothesis and model assumptions were true, a result at least this extreme would occur about 3% of the time. The American Statistical Association cautions that a p-value alone does not measure effect size, practical importance or the probability that H₀ is true.3
For most classroom and professional reports, pair the calculator result with the question you are answering. A mean or median summarizes location, but spread explains consistency. A confidence interval estimates plausible values, while a hypothesis test evaluates compatibility with a null model. Regression and correlation describe association, so they should be reported with a chart and residual or outlier review. When a result is statistically significant, still ask whether the effect is large enough to matter in the real setting.
Statistic
Small
Medium
Large
Use
Cohen's d
0.2
0.5
0.8
t-test effect size
Cramér's V
0.1
0.3
0.5
chi-square association
|r|
0.10
0.30
0.50
correlation strength
R²
0.01
0.09
0.25
variance explained
Pro Tips and Common Pitfalls
Use sample standard deviation for sampled data and population standard deviation only when the dataset is complete.
Choose the correct tail for p-values before looking at the result.
Correlation does not imply causation; inspect design, confounders and timing.
Check t-test assumptions: independence, roughly normal differences or means, comparable measurement scales and clear sampling design.
Round final results for reporting, but avoid rounding intermediate values during calculation or when comparing software output.
This calculator is for educational purposes; for formal research, verify with peer-reviewed software.
Chi Square Calculator FAQ
How do I calculate the chi-square statistic from observed and expected values?
The formula is straightforward: χ² = Σ (O − E)² / E, where O is what you observed in your data and E is what you'd expect if the null hypothesis were true. Take each cell, subtract expected from observed, square the difference, divide by the expected count, then add up all the cells. Quick example — say 60 students preferred tea and you expected 50: that contributes (60−50)²/50 = 2 to your total. Do this for every category and the sum is your chi-square value.
How do I find the p-value from a chi-square statistic?
You need two things: your chi-square value and the degrees of freedom. The p-value is the right-tail area under the chi-square distribution beyond your computed statistic. So if χ² = 7.81 with df = 3, you're looking at the probability of getting 7.81 or higher under H0 — which works out to roughly 0.05. Bigger χ² means smaller p-value. Most calculators (and software like R or Excel's CHISQ.DIST.RT) handle this lookup automatically once you enter the statistic and df.
What is the difference between chi-square goodness of fit and independence?
Goodness of fit checks whether one categorical variable follows an expected distribution. Example: are M&M colours actually 24% blue, 20% orange, etc., as the company claims? Just one variable, compared against a stated pattern. The independence test, on the other hand, uses a two-way contingency table to see if two categorical variables are related — like gender vs subject preference. Same formula in both cases, but the way you compute expected frequencies and the degrees of freedom differ. Pick based on whether you have one variable or two.
How do I calculate expected frequencies for a chi-square test?
For a contingency table, the expected count for any cell is (row total × column total) / grand total. So if 80 students fall in row 1, 120 in column 1, and the total sample is 200, that cell's expected value is (80 × 120)/200 = 48. For a goodness-of-fit test, multiply your sample size by the hypothesised proportion — like 100 × 0.25 = 25 if you're testing whether 25% of people prefer a brand. These expected counts assume H0 is true.
How do I find degrees of freedom for a chi-square test?
For a test of independence, df = (rows − 1) × (columns − 1). A 3×4 table gives (3−1)(4−1) = 6. For a goodness-of-fit test, df = number of categories − 1. So if you're checking whether a die is fair across 6 faces, df = 5. The degrees of freedom essentially tell you how many cells are free to vary once the totals are fixed — that's why we subtract one from each direction.
Can a chi-square value be negative?
No, never. Look at the formula — every term is (O − E)² divided by E. Squaring guarantees a non-negative number, and dividing by a positive expected count keeps the sign. So your χ² is always zero or positive. A value of zero only happens when observed equals expected in every single cell, meaning your data perfectly matches what H0 predicts. If you ever calculate a negative chi-square by hand, recheck your arithmetic — you've probably forgotten to square a term somewhere.
When should I use a chi-square test for a 2x2 table?
Use it when both your variables are categorical with two levels each — think smoker/non-smoker versus has-lung-issue/no-issue. Two requirements matter: observations should be independent, and expected counts in each cell should generally be at least 5. If any expected count drops below 5, switch to Fisher's exact test instead, since the chi-square approximation breaks down with small expected frequencies. For 2×2 tables specifically, some textbooks also recommend Yates' continuity correction, though opinions on that vary.
What does a significant chi-square test mean?
A significant result — typically p < 0.05 — means your observed data differs from what the null hypothesis predicted by more than chance alone would explain. So you reject H0 and conclude there's evidence of an association (in independence tests) or a difference from expected proportions (in goodness-of-fit). One important caveat I always tell my students: significance does not prove causation. The two variables may be linked, but you can't claim one causes the other from a chi-square test alone.
Chi Square Calculator Glossary
Chi-square statistic
Sum of squared observed-minus-expected differences divided by expected counts.
Observed count
The count actually seen in a category or table cell.
Expected count
The count predicted by the null model.
Goodness of fit
A test comparing observed category counts to expected counts.
Tool name: Chi Square Calculator. Computes: central tendency, spread, z scores, p values, t tests, confidence intervals, probability, sample sizes, combinations, chi-square, correlation, regression, margin of error and five number summaries. Accepted input: numeric raw data, probabilities from 0 to 1, positive standard deviations, integer counts and degrees of freedom. Output format: headline statistic, supporting metrics, formula, steps, CSV and chart. Key citations: NIST/SEMATECH e-Handbook, OpenStax Introductory Statistics, ASA p-value statement, R stats documentation.