Chi-Square Calculator

Calculate chi-square statistic and p-value from a 2×2 contingency table.

By Konstantin Iakovlev · Updated September 2026 · Source: Khan Academy

Chi-Square

16.6667

p-value

0.0000

Results

Chi-Square Statistic16.6667
p-value (approx)0.0000
Degrees of Freedom1
Significance (α=0.05)Highly Significant
Expected [1,1]30.00
Expected [1,2]20.00
Expected [2,1]30.00
Expected [2,2]20.00

Use the Chi-Square Calculator above to calculate your results. Enter your values and see instant results — all calculations run in your browser.

Disclaimer: This calculator is for informational purposes only. Results are estimates based on the information you provide and the assumptions described on this page.

How It Works

A Chi-Square test on a 2x2 contingency table tells you whether two categorical variables are genuinely associated or merely appear linked by chance. The question comes up often: a market researcher might ask whether a new ad campaign (variable 1) shifts customer purchase intent (variable 2), while a clinical team might test whether a treatment outperforms a placebo on a particular patient outcome.

Computation runs on the formula Σ((Observed - Expected)² / Expected). For every cell, the expected frequency comes from (Row Total × Column Total) / Grand Total, representing what you would see if the two variables had no relationship at all. Summing the standardized gaps between observed and expected counts produces the χ² statistic, which in turn yields a p-value, the probability of seeing an association this strong purely by chance when no real relationship exists.

Treat statistical significance and effect size as separate questions, because a small p-value signals only that the association is unlikely to be random, never that it is large or practically meaningful. The test also rests on having enough data in each cell. When more than 20% of cells carry expected counts below 5, the test's assumptions break down and the resulting p-values can no longer be trusted.

Example: Customer Preference for a New Product Feature

  1. 1 A company surveyed 500 potential customers to see whether gender is associated with preference for a new product feature: 150 men preferred it and 100 did not; 120 women preferred it and 130 did not.
  2. 2 Enter men in the first row and women in the second, preferred in the first column and not preferred in the second: Cell (1,1) = 150, Cell (1,2) = 100, Cell (2,1) = 120, Cell (2,2) = 130. Each expected count is row total × column total / 500: men who preferred it = 250 × 270 / 500 = 135, men who did not = 250 × 230 / 500 = 115, and the same 135 and 115 for women.
  3. 3 χ² = 2 × (150 − 135)² / 135 + 2 × (100 − 115)² / 115 = 3.3333 + 3.9130 = 7.2464, with (2 − 1) × (2 − 1) = 1 degree of freedom.
  4. 4 For 1 degree of freedom, χ² = 7.25 gives p ≈ 0.0071, below both 0.05 and 0.01, so the association between gender and preference is statistically significant. The p-value does not say how big the difference is; the table does: 60% of men (150 of 250) preferred the feature versus 48% of women (120 of 250).

Source: Khan Academy · Last updated: September 2026

Frequently Asked Questions

When do you use a chi-square test?
Use chi-square to test whether two categorical variables are independent. Common examples: testing if gender affects product preference, if treatment groups have different outcomes, or if survey responses differ by age group.
How do you interpret a chi-square p-value?
A p-value below 0.05 indicates a statistically significant association between the variables (reject the null hypothesis of independence). A p-value above 0.05 suggests no significant association was found.
What is the chi-square formula?
Chi-square = sum of [(observed - expected)² / expected] for each cell. Expected values are calculated as (row total x column total) / grand total. Degrees of freedom = (rows-1) x (columns-1).