Chi-square statistic, degrees of freedom and p-value from observed counts
Updated October 2026
Type raw counts, one row per line or separated by semicolons, with values in a row separated by commas: “10, 20; 30, 40” is a 2×2 table. For a test of independence, rows are the categories of one variable (say, treatment and control) and columns the categories of the other (improved, not improved). For goodness of fit, enter one list of counts and, optionally, the expected proportions in the same order (“1, 1, 2” means 25%, 25%, 50%); blank means equal. The results give χ², degrees of freedom, the p-value, the critical value, the smallest expected count (flagged below 5) and, for tables, Cramér’s V as a measure of strength from 0 to 1.
Row totals are 30 and 70, column totals 40 and 60, grand total 100. Expected counts: 30 × 40 ÷ 100 = 12, 30 × 60 ÷ 100 = 18, 70 × 40 ÷ 100 = 28 and 70 × 60 ÷ 100 = 42. Each cell contributes (O − E)² ÷ E: 4/12 + 4/18 + 4/28 + 4/42 = 0.33333 + 0.22222 + 0.14286 + 0.09524 = 0.79365. With (2 − 1) × (2 − 1) = 1 degree of freedom the p-value is 0.3730, and Cramér’s V is √(0.79365 ÷ 100) = 0.0891, a weak association.
A test of independence asks whether two categorical variables are related; degrees of freedom are (rows − 1) × (columns − 1). A goodness-of-fit test asks whether one variable’s counts match expected proportions, such as a fair die; degrees of freedom are categories − 1 (fewer if you estimated parameters from the same data, as NIST’s handbook notes). Both compare observed counts with the counts expected if the null hypothesis were true.
| Table | χ² | df | p | Significant at 0.05? |
|---|---|---|---|---|
| 10, 20 / 30, 40 (default) | 0.7937 | 1 | 0.3730 | No |
| Same proportions, ten times the counts: 100, 200 / 300, 400 | 7.9365 | 1 | 0.0048 | Yes |
| Default table with Yates correction (not applied by this calculator) | 0.4464 | 1 | 0.5040 | No |
| 2×3 table: 20, 30, 50 / 30, 30, 40 | 3.1111 | 2 | 0.2111 | No |
| Goodness of fit, 60 die rolls: 8, 12, 9, 11, 14, 6 | 4.2000 | 5 | 0.5210 | No |
Multiplying every count by ten multiplies χ² by ten, turning p = 0.373 into p = 0.0048 although the proportions are identical. Significance depends on sample size as much as on the pattern, which is why Cramér’s V (0.0891 in both tables) is worth reporting alongside p.
| Degrees of freedom | 1 | 2 | 3 | 4 | 5 | 10 |
|---|---|---|---|---|---|---|
| Critical χ² | 3.841 | 5.991 | 7.815 | 9.488 | 11.070 | 18.307 |
Entering percentages or means. The test needs raw counts. Percentages hide the sample size, which, as the table above shows, changes the answer.
Small expected counts. Penn State’s STAT 500 asks for every expected cell in a 2×2 table to be at least 5, and notes that many statisticians are wary when more than 20% of cells in a larger table fall below 5. Combine sparse categories, or use Fisher’s exact test for small 2×2 tables.
Comparing with software that applies Yates. Some programs apply a continuity correction to 2×2 tables by default. This calculator reports the uncorrected Pearson statistic; the corrected value for the default table is 0.4464 (p = 0.5040).
Counting one person twice. Each observation must fall in exactly one cell, and observations must be independent; repeated answers from the same people need a different test (McNemar’s for paired yes/no data).