Chi Square Calculator
This chi-square calculator tests whether two categorical variables are related or whether observed frequencies match what you expected. Choose a goodness of fit test when you compare one variable against a target distribution. Choose a test of independence when you want to know if two categorical variables influence each other. Enter your observed counts and the calculator returns the chi-square statistic, degrees of freedom, and p-value.
| Total | |||
|---|---|---|---|
| 40 | |||
| 40 | |||
| Total | 45 | 35 | 80 |
Not Statistically Significant
Fail to reject H₀. No significant association between the variables (χ² = 11.4286, p = 0.9993).
α = 0.05, df = 1
| Category 1 | Category 2 | |
|---|---|---|
| Group 1 | 22.50(2.500) | 17.50(3.214) |
| Group 2 | 22.50(2.500) | 17.50(3.214) |
Values in parentheses are χ² contributions. Red = high contributor.
Created by William Davis
Last updated: May 1, 2026
What is Chi Square?
Most people encounter the chi square statistic for the first time and immediately want to know what it actually measures. Here is the honest answer: it tells you how far your observed data has drifted from what you actually expected, and whether that drift is meaningful or just noise. That makes it one of the most practical tools in any statistical test toolkit, especially when your data is built around independent variables that are random or mutually exclusive.
The process starts with a large sample data pool. You run the chi-square test, you examine the discrepancies between the expected value and the actual value, and then you factor in the sample size alongside the number of variables to weigh those discrepancies properly. The degrees of freedom enter the picture next, helping you determine whether the null hypothesis should be rejected based on how many independent variables and samples are in play during the chi-square analysis.
What makes this test genuinely flexible is that its entire focus is on count data — whether those counts represent individuals, events, or items, as long as something is being counted. If you are working with rates or percentages, chi-square is not the appropriate tool. Stick to counts, keep the groups large, and the chi-square distribution will deliver reliable results every time.
Chi-Square Distribution & Formula
The chi-square distribution sits at the foundation of this entire method. In probability theory and statistics, it goes by another name too: the Central Chi-Square distribution. It is denoted by X², and its job is to carry the hypothesis-testing process from raw numbers to a decision.
Chi-Square Formula
χ² = Σ (Oi − Ei)² / Ei
E = RT × CT / GT
When to Use Chi-Square
Not every dataset calls for a chi-square test, and knowing when it applies is half the skill. The clearest trigger is when you are working with two categorical variables and want to determine whether a significant association exists between them. The classic setup is the 2×2 table, where each variable carries exactly two levels.
Requirements
Null Hypothesis (H₀)
There is no association between the two variables — they are simply independent. Everything the test does afterward is aimed at either holding that position or breaking it down.
How to Use the Chi-Square Calculator
Set significance level
Pick α (0.01, 0.05, or 0.10). Defaults to 0.05.
Choose test type
Contingency Table for two-variable association, Goodness of Fit for distribution testing.
Enter your data
Fill in observed counts. Add rows/columns as needed. Labels are optional.
Read live results
χ², df, p-value, critical value, and decision update instantly as you type.
Decimals are fine for expected counts as long as they represent actual counts, not percentages. For example, 15% of 250 individuals becomes 37.5 — a valid entry.
Steps to Calculate Manually
Working through the chi-square distribution by hand at least once builds intuition that a calculator alone cannot give you.
Write hypotheses
State your null hypothesis H₀ and alternate hypothesis H₁ clearly before touching any numbers.
Build the observed table
Lay out your raw counts and compute row totals, column totals, and the grand total.
Calculate expected values
For each cell: E = (Row Total × Column Total) / Grand Total.
Compute contributions
For each cell: (O − E)², then divide by E to get (O − E)² / E.
Sum to get χ²
Add all (O − E)² / E values. That sum is your chi-square test statistic.
Find degrees of freedom
df = (rows − 1) × (columns − 1) for contingency tables.
Compare to critical value
If χ² > critical value, reject H₀. Otherwise, fail to reject.
Assumptions of Chi-Square
Count data only
You must be analyzing counts, not percentages or proportions.
Min expected ≥ 5
Each cell's expected frequency should be at least 5 for stable results.
Theoretical basis
Data must compare against a theoretical distribution, not an arbitrary one.
How to Find Expected Frequencies
One of the questions that comes up most consistently when people first use chi-square calculators is where the expected frequencies come from. The logic behind them is worth understanding before you enter a single number.
The simplest assumption is equal groups. If you have 605 observations across 5 groups, then 121 per group is your baseline. Decimals are acceptable as long as expected frequencies add up to the total observations. Expected counts can reflect previous research, a known distribution, or any factors relevant to your study design.
Contingency tables
Expected counts are built automatically under the assumption that the two factors are not related — which is exactly what the null hypothesis states.
Interpreting Results
p < α (e.g. 0.05)
Reject H₀. The observed counts differ from the expected counts in a statistically meaningful way. Something real is happening in the data.
p ≥ α (e.g. 0.05)
Fail to reject H₀. No significant deviation detected. This does not confirm no difference — you may simply lack enough data to detect one.
Every result comes paired with the chi-squared statistic and its degrees of freedom. Category names play no role in interpretation; only the numbers matter.
Chi-Square Examples
H₀: μ₁ = μ₂ vs H₁: μ₁ ≠ μ₂, tested at 5% significance.
Observed Counts
| Category 1 | Category 2 | Total | |
|---|---|---|---|
| Group 1 | 64 | 56 | 120 |
| Group 2 | 42 | 28 | 70 |
| Total | 106 | 84 | 190 |
Expected Counts
| Category 1 | Category 2 | |
|---|---|---|
| Group 1 | 66.947 | 53.053 |
| Group 2 | 39.053 | 30.947 |
Calculation Table
| O | E | O − E | (O − E)² | (O − E)² / E |
|---|---|---|---|---|
| 64 | 66.947 | −2.947 | 8.6848 | 0.1297 |
| 56 | 53.053 | 2.947 | 8.6848 | 0.1637 |
| 42 | 39.053 | 2.947 | 8.6848 | 0.2223 |
| 28 | 30.947 | −2.947 | 8.6848 | 0.2806 |
| χ² Total | 0.7963 | |||
df = (2−1) × (2−1) = 1
Critical value at α=0.05, df=1 = 0.3720
Decision: 0.7963 > 0.3720 → Reject H₀
605 subjects distributed across five categories, testing against equal expected distribution (121 per group).
Group A
200
obs.
Group B
102
obs.
Group C
50
obs.
Group D
153
obs.
Group E
100
obs.
Related Tests and Calculators
Contingency Tables
For 2×2 tables, expected counts are calculated automatically under the independence assumption. Includes optional Yates' correction for small samples.
Binomial Test
Better than chi-square when data has exactly two categories. Calculates an exact P value, avoiding the deflation risk chi-square carries in that scenario.
Chi-square works on counts across categories. The t-test works on means. Count data → chi-square. Continuous means → t-test. Keep the boundary clear.
Frequently Asked Questions
What is a chi-square test in chi-square analysis?
A chi-square test compares observed results against expected results within any chi square analysis. It measures whether the difference between the observed value and the expected value is explainable by chance or points to a real relationship between variables. It's best suited to large sample sizes where results carry enough statistical weight to be meaningful.
What is a Chi-Square Test Used for?
This statistical test is used whenever you need to examine differences between an observed value and an expected value across categorical variables. It works best with large datasets built from random sample data, where counts across categories are high enough to produce stable and trustworthy output.
Is chi-square negative?
No. The chi square value cannot be negative because it is computed as the sum of squared values, and squares are always positive. The minimum χ² can reach is zero, which only happens when every observed count perfectly matches its expected count.
How to calculate chi squared value?
Apply X² = Σ (Oᵢ − Eᵢ)² / Eᵢ. For each observation: subtract the expected value from observed, square the difference, then divide by the expected value. Repeat for every data point, then sum all results.
What is a good chi-square value?
A reliable chi-square value comes from data where every cell's expected frequency is at least 5. When that condition is met, the chi-square value reflects something real. Below that threshold, the value becomes difficult to interpret with confidence.