Chi-Square Calculator
Settings
Use counts, not percentages, and check that expected counts are large enough (often at least 5).
Results
Action
Use this Chi-Square Calculator to run a chi-square test of independence, a chi-square goodness-of-fit test, or a chi-square distribution lookup for p-values and critical values. It is useful for statistics homework, survey tables, categorical data analysis, observed-count comparisons, and quick hypothesis-test checking.
Reviewed by: AjaxCalculators Editorial Team
Last updated: May 3, 2026
Method source: Standard chi-square test formulas for categorical count data, including independence tests, goodness-of-fit tests, and right-tail chi-square distribution values
Editorial standards: AjaxCalculators Editorial Policy
What This Chi-Square Calculator Calculates
This calculator supports three related chi-square utilities:
- Chi-square test of independence: tests whether two categorical variables appear associated in a contingency table
- Chi-square goodness-of-fit test: compares observed category counts with expected category counts or expected proportions
- Chi-square distribution utility: finds right-tail p-values and critical chi-square values from a statistic and degrees of freedom
Depending on the mode selected, it can show:
- χ² statistic
- Degrees of freedom, also written as df
- Right-tail p-value
- Critical χ² value
- Decision at α
- Expected counts
- Cell contributions
- Total N
What Is a Chi-Square Test?
A chi-square test is a statistical method for comparing observed categorical counts with expected counts under a null hypothesis.
The general idea is simple:
- If observed counts are close to expected counts, the chi-square statistic is small.
- If observed counts are far from expected counts, the chi-square statistic is larger.
- A larger chi-square statistic usually produces a smaller right-tail p-value.
Chi-square tests are used with counts, not raw percentages alone. For example, a table of survey responses by group can be tested, but a table of percentages should usually be converted back to counts before using a chi-square test.
Core Chi-Square Formula
Both the independence test and the goodness-of-fit test use the same basic test statistic:
χ² = Σ (O − E)² / E
Where:
- χ² = chi-square test statistic
- O = observed count
- E = expected count under the null hypothesis
- Σ = sum across all cells or categories
Each cell or category contributes (O − E)² / E to the overall statistic. Larger contributions show where the observed counts differ most from the expected counts.
Chi-Square Test of Independence
The chi-square test of independence is used for a contingency table with two categorical variables. It tests whether the row variable and column variable appear independent or associated.
Examples include:
- survey response by age group
- product preference by region
- pass/fail result by training method
- category choice by customer segment
For an r × c contingency table, the degrees of freedom are:
df = (r − 1)(c − 1)
Where:
- r = number of rows
- c = number of columns
Expected Counts for the Independence Test
In an independence test, the expected count for each cell is calculated from row totals, column totals, and the grand total.
Expected count = (row total × column total) / grand total
This expected count represents what the cell count would be if the two categorical variables were independent.
Chi-Square Goodness-of-Fit Test
The chi-square goodness-of-fit test compares observed category counts with expected category counts or expected proportions.
Examples include:
- checking whether a die appears fair
- comparing observed category counts with expected market shares
- testing whether survey responses match a hypothesized distribution
- checking whether observed counts follow specified category probabilities
The test statistic is:
χ² = Σ (O − E)² / E
When expected category probabilities are fully specified in advance, the degrees of freedom are usually:
df = k − 1
Where:
- k = number of categories
If expected probabilities or model parameters are estimated from the same data, degrees of freedom may need additional adjustment.
Chi-Square Distribution Utility
The distribution mode uses a chosen degrees-of-freedom value and a chi-square statistic to compute a right-tail probability.
p = P(Χ² ≥ x)
Where:
- x = chi-square statistic
- df = degrees of freedom
- p = right-tail probability
This mode can also return a right-tail critical value for a selected significance level α.
Formula Summary
| Calculation | Formula | Use |
|---|---|---|
| Chi-square statistic | χ² = Σ (O − E)² / E | Compare observed counts with expected counts |
| Independence expected count | E = (row total × column total) / grand total | Find expected cell counts in a contingency table |
| Independence df | df = (r − 1)(c − 1) | Degrees of freedom for an r × c table |
| Goodness-of-fit expected count | E = n × expected proportion | Find expected category counts |
| Goodness-of-fit df | df = k − 1 | Used when expected probabilities are fully specified |
| Right-tail p-value | p = P(Χ² ≥ x) | Probability of a result at least this large under the null model |
Mode Comparison
| Mode | Input Type | Main Question | Example |
|---|---|---|---|
| Independence test | Contingency table of observed counts | Are two categorical variables associated? | Is product preference related to region? |
| Goodness-of-fit test | Observed and expected category counts or proportions | Do observed counts match a specified distribution? | Does a die appear fair? |
| Distribution utility | χ² value and degrees of freedom | What is the right-tail p-value or critical value? | Find p for χ² = 8.4 and df = 3 |
Observed Counts vs Expected Counts
Chi-square tests compare what you observed with what would be expected under a null hypothesis.
| Count Type | Meaning | Example |
|---|---|---|
| Observed count | The count actually recorded in the data | 35 people chose option A |
| Expected count | The count expected under the null hypothesis | 30 people would be expected to choose option A if the null model were true |
| Cell contribution | The part of χ² contributed by one cell or category | (35 − 30)² / 30 = 0.83 |
Large cell contributions help identify where the biggest differences between observed and expected counts occur.
Worked Example A: Goodness-of-Fit Test
Suppose you observe counts across 4 categories:
- Observed: 18, 22, 25, 15
- Expected: 20, 20, 20, 20
Step 1: Compute each contribution
| Category | Observed O | Expected E | (O − E)² / E |
|---|---|---|---|
| 1 | 18 | 20 | (18 − 20)² / 20 = 0.20 |
| 2 | 22 | 20 | (22 − 20)² / 20 = 0.20 |
| 3 | 25 | 20 | (25 − 20)² / 20 = 1.25 |
| 4 | 15 | 20 | (15 − 20)² / 20 = 1.25 |
Step 2: Add the contributions
χ² = 0.20 + 0.20 + 1.25 + 1.25 = 2.90
Step 3: Find degrees of freedom
df = k − 1 = 4 − 1 = 3
Step 4: Interpret the result
The calculator uses χ² = 2.90 and df = 3 to find the right-tail p-value. If a significance level is entered, it can also show the critical χ² value and decision.
Worked Example B: Test of Independence
Suppose you enter this 2 × 3 contingency table of observed counts:
| Group | Option A | Option B | Option C | Row Total |
|---|---|---|---|---|
| Group 1 | 20 | 30 | 10 | 60 |
| Group 2 | 30 | 20 | 30 | 80 |
| Column Total | 50 | 50 | 40 | 140 |
Step 1: Compute an expected count
For Group 1 and Option A:
E = (row total × column total) / grand total
E = (60 × 50) / 140 ≈ 21.43
Step 2: Compute the cell contribution
(O − E)² / E = (20 − 21.43)² / 21.43 ≈ 0.10
Step 3: Repeat for every cell
The calculator calculates expected counts and contributions for each cell, then sums the contributions to get the overall χ² statistic.
Step 4: Find degrees of freedom
For a 2 × 3 table:
df = (2 − 1)(3 − 1) = 2
Result: The calculator returns the χ² statistic, df, right-tail p-value, critical value if α is entered, and the decision.
Worked Example C: Distribution Lookup
Suppose you want the right-tail p-value for:
- χ² statistic: 8.40
- Degrees of freedom: 3
The calculator evaluates:
p = P(Χ² ≥ 8.40)
This p-value represents the probability of seeing a chi-square statistic at least as large as 8.40 if the null model and degrees of freedom are correct.
If α is also entered, the calculator can compare the statistic with the critical χ² value for that α level.
Right-Tail p-Values and Critical Values
Chi-square tests are usually right-tail tests because larger χ² statistics indicate larger disagreement between observed and expected counts.
| Output | Meaning | How to Use It |
|---|---|---|
| Right-tail p-value | Probability of χ² at least as large as the observed statistic under the null model | Compare with α |
| Critical χ² value | Cutoff value for the selected α and df | Reject the null if χ² is at or above the cutoff |
| α level | Chosen significance threshold | Common examples are 0.10, 0.05, and 0.01 |
| Decision | Reject or fail to reject the null hypothesis | Use with context, assumptions, and study design |
Expected Count Assumptions
Chi-square p-values are based on an approximation. The approximation works better when expected counts are not too small.
A common practical guideline is:
- Expected counts should generally be at least about 5, or
- Most expected counts should be at least 5, with no extremely small expected counts.
Different textbooks and software notes may phrase this rule differently. If expected counts are too small, an exact test, simulation method, category combining, or another approach may be more appropriate.
Independence Test vs Goodness-of-Fit Test
| Feature | Independence Test | Goodness-of-Fit Test |
|---|---|---|
| Data layout | Two-way contingency table | One list of categories |
| Main purpose | Test association between two categorical variables | Test whether counts match expected counts or proportions |
| Expected counts | Computed from row totals and column totals | Computed from expected proportions or entered expected counts |
| Typical df | (r − 1)(c − 1) | k − 1 when probabilities are fully specified |
| Example | Preference by region | Observed die rolls vs fair-die expectation |
Statistical Significance vs Practical Importance
A small p-value can show that observed counts differ from expected counts more than would be expected by chance under the null model. However, statistical significance does not automatically mean the result is practically important.
To interpret a chi-square result well, consider:
- sample size
- cell contributions
- effect size, such as Cramér’s V for association tables
- study design
- data quality
- whether categories were chosen before seeing the data
- whether multiple tests were performed
Cell Contributions and Follow-Up Interpretation
The overall χ² statistic tells you whether the table as a whole shows a difference from expected counts. It does not automatically explain which cells are responsible.
Cell contributions help identify where the largest differences occur:
Cell contribution = (O − E)² / E
A large contribution means that cell has a larger observed-versus-expected difference relative to its expected count.
For deeper interpretation, statistical software may also show residuals or standardized residuals. These can help identify which cells contribute most to the association or lack of fit.
How to Use This Chi-Square Calculator
- Select Independence test, Goodness-of-fit, or Distribution mode.
- If needed, enter α to get a critical χ² value and decision.
- For independence mode, enter the observed contingency table counts.
- For goodness-of-fit mode, enter observed and expected counts or expected proportions for each category.
- For distribution mode, enter df and a chi-square value.
- Click Calculate if the tool requires it.
- Review χ², df, p-value, critical value, expected counts, cell contributions, and the decision.
- Check expected-count assumptions before relying on the p-value.
How to Interpret the Result
χ² statistic measures how far the observed counts are from the expected counts under the null model.
Degrees of freedom determine which chi-square distribution is used.
Right-tail p-value tells you how unusual a result at least this large would be if the null hypothesis were true.
Critical χ² is the cutoff for the selected α level.
If p ≤ α, the result is usually treated as statistically significant and the null hypothesis is rejected.
If p > α, the result is usually not statistically significant at that α level, and you fail to reject the null hypothesis.
| Result Pattern | Possible Meaning | What to Check |
|---|---|---|
| Large χ² statistic | Observed counts differ more from expected counts | Review p-value, cell contributions, and assumptions |
| Small p-value | Observed pattern is unlikely under the null model | Check practical importance and study design |
| Large p-value | Data do not provide strong evidence against the null model | Check sample size and expected counts |
| Small expected counts | Chi-square approximation may be unreliable | Consider exact, simulated, or alternative methods |
| One cell has a large contribution | That cell strongly affects the overall statistic | Investigate the cell and category context |
When This Calculator Is Useful
This calculator is useful for categorical count data and introductory hypothesis-test checking.
- Test whether two categorical variables are independent
- Compare observed counts with expected counts
- Run a goodness-of-fit test for category counts
- Look up right-tail p-values for a chi-square statistic
- Find a critical χ² value from df and α
- Check cell-level contributions in contingency tables
- Support survey-table and categorical-data homework
- Verify hand calculations or spreadsheet results
When You May Need More Than This Calculator
A chi-square calculator is useful for quick checks, but more advanced analysis may be needed when:
- expected counts are small
- the table is sparse or has many categories
- the data are paired or repeated measures
- the observations are not independent
- survey weights or complex sampling are involved
- categories were combined after seeing results
- you need exact tests such as Fisher’s exact test
- you need effect sizes such as Cramér’s V
- you need residual analysis or post-hoc comparisons
- you are using results for research, publication, medical, legal, policy, financial, or high-stakes decisions
Common Mistakes to Avoid
- Entering percentages instead of counts: chi-square tests need observed counts, not percentages alone.
- Using chi-square for raw continuous data: chi-square tests are for categorical count data.
- Ignoring expected-count rules: small expected counts can make the approximation unreliable.
- Confusing independence and goodness-of-fit: independence uses a two-way table, while goodness-of-fit compares one set of categories with expected counts.
- Assuming significance proves causation: chi-square association does not prove one variable causes another.
- Ignoring effect size: a significant result may still be small in practical terms.
- Overlooking cell contributions: the overall χ² statistic does not show which cells caused the pattern by itself.
- Using dependent observations: standard chi-square tests assume observations are independent.
- Changing categories after seeing results: post-hoc category choices can distort interpretation.
Assumptions and Important Notes
- This calculator is for categorical count data, not for means or raw continuous measurements.
- Chi-square tests are usually interpreted using the right tail of the chi-square distribution.
- Expected counts should generally be large enough for the chi-square approximation to work well.
- In independence mode, the observed table should contain counts, not percentages.
- In goodness-of-fit mode, expected values must be positive.
- Observed counts should be non-negative whole-number counts.
- Rows and columns should represent meaningful categories.
- Standard chi-square tests assume independent observations.
- A statistically significant result does not tell you how strong or important the association is by itself.
- The calculator does not automatically adjust for survey weights, repeated measures, multiple testing, or complex sampling designs.
Practical Uses of a Chi-Square Calculator
- Analyze survey response tables
- Check categorical association between two variables
- Compare observed counts with expected counts
- Test whether category counts fit a specified distribution
- Find p-values from chi-square statistics
- Find critical chi-square values for selected α levels
- Review expected counts and cell contributions
- Support statistics homework and introductory categorical-data analysis
References
- Penn State STAT 500: Chi-Square Test for Independence
- Penn State STAT 200: Goodness-of-Fit Test
- Penn State STAT 200: Expected Counts and Chi-Square Approximation
- Penn State STAT ONLINE: Chi-Square Tests Review
- NIST/SEMATECH e-Handbook of Statistical Methods: Chi-Square Goodness-of-Fit Test
- McHugh ML: The Chi-Square Test of Independence
Related Calculators
- t-test Calculator
- t-statistic Calculator
- Sample Size Calculator
- Margin of Error Calculator
- Power Analysis Calculator
- Standard Deviation Calculator
- Variance Calculator
Frequently Asked Questions
What does this Chi-Square Calculator calculate?
It calculates chi-square statistics, degrees of freedom, right-tail p-values, critical values, decisions at α, expected counts, and cell contributions for supported chi-square modes.
What is a chi-square test used for?
A chi-square test is used to compare observed categorical counts with expected counts under a null hypothesis.
What is the chi-square test statistic formula?
The formula is χ² = Σ (O − E)² / E, where O is an observed count and E is an expected count.
What is a chi-square test of independence?
It is a test for whether two categorical variables in a contingency table appear independent or associated.
What is a chi-square goodness-of-fit test?
It compares observed counts in categories with expected counts or expected proportions under a specified model.
What data should I enter for an independence test?
Enter observed counts in a two-way contingency table. Do not enter percentages alone.
What data should I enter for a goodness-of-fit test?
Enter observed category counts and expected counts or expected proportions for the same categories.
How are expected counts calculated in an independence test?
Each expected count is calculated as (row total × column total) / grand total.
What are degrees of freedom for an independence test?
For an r × c table, degrees of freedom are (r − 1)(c − 1).
What are degrees of freedom for a goodness-of-fit test?
When expected probabilities are fully specified, degrees of freedom are usually k − 1, where k is the number of categories.
Why is the chi-square p-value right-tailed?
Larger chi-square values show larger disagreement between observed and expected counts, so the p-value is usually the probability of a statistic at least as large as the observed value.
What does p ≤ α mean?
It usually means the result is statistically significant at the selected α level, so the null hypothesis is rejected.
What does p > α mean?
It usually means the result is not statistically significant at the selected α level, so you fail to reject the null hypothesis.
What are cell contributions?
Cell contributions show how much each cell or category contributes to the total chi-square statistic.
Does a significant chi-square result prove causation?
No. A significant association does not prove causation. Study design, confounding, sampling, and context still matter.
Can I use chi-square with percentages?
Not directly. Chi-square tests require counts. Percentages alone usually do not provide enough information because the sample size matters.
What if expected counts are small?
Small expected counts can make the chi-square approximation unreliable. Consider exact tests, simulation, category combining, or qualified statistical guidance.
Can this calculator replace statistical software?
No. It is useful for learning and quick checks, but full statistical software may be needed for exact tests, residual analysis, effect sizes, survey weights, or complex designs.
Disclaimer: This Chi-Square Calculator provides educational statistical estimates for chi-square tests of independence, chi-square goodness-of-fit tests, and right-tail chi-square distribution lookups. Results depend on the selected mode, observed counts, expected counts or expected proportions, table structure, degrees of freedom, significance level, rounding, and whether the chi-square approximation is appropriate. The calculator is designed for categorical count data, not raw continuous measurements, averages, percentages alone, or paired numeric data. Expected counts should generally be large enough for chi-square approximation methods to work reasonably well; small expected counts, sparse tables, or very small samples may require exact tests, category combining, simulation methods, or qualified statistical review. A statistically significant result does not prove causation, practical importance, or which specific categories explain the pattern by itself. Use cell contributions, residuals, effect sizes, study design, and subject-matter context when interpreting results. Use this calculator for learning, homework, and quick categorical-data checks, and use full statistical software or qualified statistical guidance for research, publication, medical, legal, policy, financial, or high-stakes decisions.