Chi-Square Calculator
Run a Pearson chi-square (χ²) test of independence on a contingency table, or a goodness-of-fit test comparing observed counts to expected counts. The calculator reports χ², the degrees of freedom, and the p-value (the probability of seeing a χ² at least this large under the null hypothesis). For contingency tables, expected counts are derived from the row and column totals; for goodness-of-fit, you may supply expected counts or let the calculator assume a uniform distribution. The p-value uses the regularized upper incomplete gamma function via series and continued-fraction expansions. Everything runs locally in your browser.
Each line is a row; cells separated by commas, tabs, or spaces.
χ² = Σ (O − E)² / E. For a contingency table df = (rows − 1)(cols − 1); for goodness of fit df = (categories − 1) (or minus one more if expected counts were estimated). E for a table cell = (row total × column total) / grand total. The p-value = upper incomplete gamma γ(df/2, χ²/2) / Γ(df/2), computed with series (small χ²) and continued-fraction (large χ²) expansions — values match standard chi-square tables. A small p (e.g. < 0.05) is evidence against the null hypothesis. Runs locally.