Chi-Square Test of Independence (Contingency Table)
Cross-tabulates two categorical variables (rows x columns) and tests whether they are associated.
Example
You enter
- Contingency table (one row per line; cells separated by spaces or commas) 10 20 30 30 20 10
You get
- Chi square 20
- Cramer's V (effect size) V = 0.408
Details, formula, and sources
Paste the r x c table one row per line; it builds the expected counts from the margins - E = row total x column total / grand total, what you would see if the variables were unrelated - then chi2 = sum (observed - expected)^2 / expected on (r-1)(c-1) df, with the p-value from the bundled chi-square CDF. A 2x3 table 10/20/30 over 30/20/10 gives chi2 = 20.0 on 2 df, p = 4.5e-5 - the row and column variables are related. Also reports Cramer's V = sqrt(chi2/(N min(r-1,c-1))), the association strength from 0 to 1, and warns when an expected cell drops below 5. Verified against scipy.stats.chi2_contingency. A statistics aid; the study design governs.
Expected E[i][j] = row_total_i * col_total_j / N; chi-square = sum((observed - expected)^2 / expected) on (r-1)(c-1) degrees of freedom; p-value = 1 - chi2Cdf(chi-square, df). Cramer's V = sqrt(chi-square / (N * min(r-1, c-1))).
OpenIntro Statistics 4th ed. Chapter 6 (inference for categorical data, two-way tables) by name; the chi-square CDF via the regularized lower incomplete gamma function per Numerical Recipes in C 2nd ed. §6.2. Verified against scipy.stats.chi2_contingency (correction=False).
OpenIntro Statistics free at openintro.org; Numerical Recipes chapters free at numerical.recipes.
Estimate only. Readability formulas and similar metrics are derived from a representative population and have known edge-case noise. The classroom teacher governs final text selection, grade placement, and assessment decisions.
Field names used by the API: table_text, chi_square, cramers_v
- Expected from margins E[i][j] = row_total_i * col_total_j / N (the counts under independence)OpenIntro Statistics Ch. 6
- Degrees of freedom (r-1)(c-1) for an r x c tableOpenIntro Statistics Ch. 6
- Effect size and scope Cramer's V = sqrt(chi2/(N min(r-1,c-1))); no Yates correction (matches scipy correction=False); expected cells should be at least 5scope of this tile