A/B tests · For studentsChi-square test calculator

An online chi-square test solved step by step: a contingency table up to 10 × 10 and a goodness-of-fit test, with the Yates correction and Fisher's exact test for 2 × 2. Expected counts with cells below five highlighted, residuals, Cramér's V, the critical value, pasting a table from Excel, and Python and R code.

Your numbers stay in the browser and are never sent anywhere

01Data02Result03Expected and residuals04Step by step05Code06Problems07Questions08Related
01

Data

Mode

Contingency table — are two variables related: rows are one grouping (sex, page variant), columns another (plan, bought or not). Up to 10 × 10.

Observed counts
123ΣA100B100Σ5050100200

You can paste a whole table from Excel: click any cell and press Ctrl+V. Row and column labels are recognised.

α = 0.05 · two-sided test
02

Result

No association shown
The differences between rows could be due to chance: χ² = 4.00, p = 0.1353 is above α = 0.05.
Chi-square statistic
4.000
no correction
p-value
0.1353
threshold α = 0.05
Degrees of freedom
2
(r − 1)(c − 1)
Critical value
5.991
threshold α = 0.05
Strength, Cramér's V
0.141
weak
03

Expected and residuals

Expected counts
If there is no association. Below 5 is highlighted
123A252550B252550
Standardised residuals
Adjusted: above 2 in absolute value — the cell drives the association
123A+1.63−1.630.00B−1.63+1.630.00
04

Step by step

  1. 1
    Data
    A 2 × 3 table, N = 200 observations in total.
  2. 2
    Hypotheses
    H₀: rows and columns are independentH₁: they are associated
  3. 3
    Expected counts
    E11 = R1 · C1N = 100 · 50200 = 25(row total × column total / N)
  4. 4
    The χ² statistic
    χ² = Σ (O − E)²E = (30 − 25)²25 + (20 − 25)²25 + (50 − 50)²50 + … (6 terms) = 4.000
  5. 5
    Critical value and p-value
    df = (2 − 1)(3 − 1) = 2χ²crit(0.05; 2) = 5.991p = P(χ² > 4.000) = 0.1353
  6. 6
    Conclusion
    χ² = 4.000 ≤ χ² crit = 5.991, p ≥ α — no grounds to reject H₀. Cramér's V = 0.141 — a weak association.
05

Check in Python / R

Check in Python / R
from scipy.stats import chi2_contingency

chi2_contingency([[30, 20, 50], [20, 30, 50]], correction=False)
06

Problems

07

Frequently asked questions

When the data are categorical: you count items rather than measure quantities. The test of independence checks whether two variables are related, such as sex and plan, or page variant and purchase. Goodness of fit checks whether counts match expected shares. For two conversion rates a 2 × 2 chi-square equals the z-test: 1,600 of 80,000 against 1,696 of 80,000 gives p = 0.091 in both.

Updated