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
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.
In a contingency table, multiply the row total by the column total and divide by the grand total. In [[30, 20, 50], [20, 30, 50]] each row holds 100 observations, the first column 50, and the total is 200: the expected count is 100 · 50 / 200 = 25. In a goodness-of-fit test the expected count is the total times the category share: for a die it is 100 / 6 ≈ 16.7.
The χ² approximation becomes inaccurate and p may come out too small. For a 2 × 2 table use Fisher's exact test: [[3, 7], [8, 2]] expects 5.5 and 4.5, chi-square without a correction gives p = 0.025 and Fisher gives 0.070. In larger tables merge rare categories. The calculator highlights such cells and suggests Fisher by itself.
A continuity correction for 2 × 2 tables: before squaring, the absolute difference between observed and expected counts is reduced by 0.5. Chi-square gets smaller and the conclusion more cautious. For [[3, 7], [8, 2]] chi-square is 5.05 with p = 0.025 without the correction and 3.23 with p = 0.072 with it. With large counts the difference almost vanishes; with small ones Fisher is more accurate.
The strength of the association from 0 to 1, which, unlike p, does not grow with the sample size. The table [[60, 40], [40, 60]] and the same table ten times larger both give V = 0.2, yet p = 0.005 and 4·10⁻¹⁹. Below 0.1 the association is very weak, below 0.3 weak, below 0.5 moderate, above that strong. For 2 × 2 tables V equals the φ coefficient.
Goodness of fit compares one row of counts with shares known in advance: is a die fair, does the customer mix match the plan. Its degrees of freedom are the number of categories minus one. Independence checks the relation of two variables in a table whose expected counts come from the data, with df = (rows − 1)(columns − 1). A die rolled 16, 18, 16, 14, 12, 24 gives χ² = 5.12 at df = 5.