Chi-Square CalculatorChi-Square Calculator
Trust

How the Calculator Is Built and Tested

Every number on this site comes from one statistics engine. Here is how it computes, and the published results it must reproduce before any page is built.

At a glance

Engine test cases
25 of 25 pass
SciPy cross-check
8,100 values
Engine version
1.0.0
Last checked
November 21, 2026
On this page

Who checks the numbers

There is no statistician on staff, and no outside statistician has reviewed the site. The check on every figure is mechanical instead: the build compares the engine with the published R, NIST, SciPy and textbook results listed below, and refuses to publish if any of them disagree. James Graham, the editor, reviews the pages and the test list; the about page says more about him and the publisher.

Numerical methods

Chi-square p-values are the regularized upper incomplete gamma function Q(k/2, χ²/2) (NIST DLMF chapter 8). The engine evaluates it with the power series when χ²/2 is below k/2 + 1 and with Legendre's continued fraction (modified Lentz method) otherwise, computing the tail that is needed directly so small p-values keep full relative accuracy. For large degrees of freedom the prefactor is computed in a form that avoids cancellation, following the approach described by DiDonato and Morris (DiDonato and Morris 1986).

Critical values start from the Wilson-Hilferty approximation and are refined by safeguarded Newton steps on the exact tail. Fisher's exact test adds hypergeometric probabilities computed on the log scale, with R's relative tolerance of one part in ten million when deciding which tables are "no more likely" than the observed one. R's conditional odds ratio and its exact confidence interval are found by bisection to full double precision.

The same engine file runs when the pages are built and in your browser, and one rounding function formats every number in both places, so the default results in the page and the results after you edit always agree.

Accuracy targets and results

Targets: relative error below one part in ten billion for p-values and critical values against SciPy, which uses the Boost math library, and agreement with every digit that R or NIST prints. R and SciPy differ from each other only in the last few digits of conditional odds ratio intervals, because R stops its root finder early; there we match R to four significant figures.

On the last build all 25 test cases passed, and all 8,100 stored SciPy 1.18.1 values (chi-square tails, quantiles and Fisher p-values for random inputs) agreed, with a worst relative error of 1.9 × 10−12. The build stops if any case fails.

Every test case

Kinds are labeled plainly: published reference output was printed by R or SciPy themselves; an official table is NIST's; a textbook example has a printed result we match; historical data means the counts are published but the result is our calculation; constructed cases are our own tables built to test a rule.

No.KindSourceOur valueResult
1Published reference output (R or SciPy)R chisq.test example: party identification by gender (Agresti)χ² 30.0701, df 2, p 2.954 × 10−7Pass
2Published reference output (R or SciPy)R chisq.test example: 2x2 table, Yates correctionYates χ² 0.6411, p 0.4233Pass
3Published reference output (R or SciPy)R chisq.test example: three counts against equal sharesχ² 2.5000, df 2, p 0.2865Pass
4Published reference output (R or SciPy)R chisq.test example: five counts against stated proportionsχ² 9.9901, df 4, p 0.0406Pass
5Published reference output (R or SciPy)R chisq.test example: small expected count warningχ² 5.7947, df 4, p 0.2150Pass
6Historical data; result computed by usMendel's pea counts (1866) against 9:3:3:1χ² 0.4700, df 3, p 0.9254Pass
7Textbook or course exampleOpenStax Introductory Statistics 2e, Example 11.6: volunteer hoursχ² 12.9909, df 4, p 0.0113Pass
8Textbook or course exampleOpenStax Introductory Statistics 2e, Example 11.2: absences by weekdayχ² 3.0000, df 4, p 0.5578Pass
9Textbook or course exampleUniversity of Wisconsin Statistics 571 (2003): 3x3 tableχ² 1.8571, df 4, p 0.7620Pass
10Published reference output (R or SciPy)SciPy chi2_contingency documentation example (with G-test)χ² 2.7778, df 2, p 0.2494Pass
11Published reference output (R or SciPy)SciPy chisquare documentation examplesχ² 2.0000, df 5, p 0.8491Pass
12Published reference output (R or SciPy)R fisher.test example: Fisher's tea tastingtwo-sided p 0.4857Pass
13Published reference output (R or SciPy)R fisher.test example: convictions of twins (Fisher 1962)two-sided p 5.367 × 10−4Pass
14Published reference output (R or SciPy)SciPy fisher_exact documentation exampletwo-sided p 0.0350Pass
15Official table (NIST)NIST/SEMATECH e-Handbook chi-square critical value tabledf 1, 0.05: 3.841; df 100, 0.001: 149.449Pass
16Reference value from SciPySciPy 1.17.1 reference values for tails and quantiles14 tail and quantile valuesPass
17Our constructed caseOur 2x2 table testing the Yates cap and phiYates χ² 2.6667, Fisher p 0.1000Pass
18Our constructed caseOur 2x2 table testing the N-1 chi-square (Campbell 2007)N−1 χ² 12.1600, p 4.883 × 10−4Pass
19Our constructed caseAPA 7 formatting of a chi-square resultχ²(2, N = 2,757) = 30.07, p < .001Pass
20Our constructed caseAPA 7 formatting of a chi-square resultχ²(4, N = 839) = 12.99, p = .011Pass
21Our constructed caseAPA 7 formatting check for the shared number formatterformatting matchesPass
22Our constructed caseAPA 7 formatting check for the shared number formatterformatting matchesPass
23Our constructed caseAPA 7 formatting check for the shared number formatterformatting matchesPass
24Published reference output (R or SciPy)R mcnemar.test example: approval in two surveys (Agresti)χ² 16.818, p 4.115 × 10−5Pass
25Published reference output (R or SciPy)R binom.test example: dwarf and giant plants (Conover)p 0.3825Pass

R is not installed on the build machine, so R values come from R's own reference output file, stats-Ex.Rout.save (R reference output), and NIST values from the e-Handbook (NIST table).

What the engine does not do yet

  • Exact tests for tables larger than 2x2 (Freeman-Halton) and Monte Carlo p-values.
  • A bias-corrected Cramér's V and confidence intervals for V.
  • An exact multinomial test for goodness of fit.

Sources and recheck schedule

Software behavior is rechecked every 180 days, style guidance and published sources every 365 days. The build refuses to publish when a source is badly overdue.

SourceRecheck groupChecked
R source code, chisq.test (stats package)reference software, every 180 daysNovember 21, 2026
R reference example output, stats-Ex.Rout.savereference software, every 180 daysNovember 21, 2026
R documentation: the chi-squared distribution (pchisq, qchisq)reference software, every 180 daysNovember 21, 2026
SciPy documentation: scipy.stats.chi2_contingencyreference software, every 180 daysNovember 21, 2026
SciPy documentation: scipy.stats.chisquarereference software, every 180 daysNovember 21, 2026
SciPy documentation: scipy.stats.fisher_exactreference software, every 180 daysNovember 21, 2026
SciPy documentation: scipy.special.gammaincreference software, every 180 daysNovember 21, 2026
Microsoft Support: CHISQ.TEST functionreference software, every 180 daysNovember 21, 2026
NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.7.4: critical values of the chi-square distributionsources, every 365 daysNovember 21, 2026
NIST Digital Library of Mathematical Functions, chapter 8: incomplete gamma and related functionssources, every 365 daysNovember 21, 2026
OpenStax, Introductory Statistics 2e, section 11.3: test of independencesources, every 365 daysNovember 21, 2026
OpenStax, Introductory Statistics 2e, section 11.2: goodness-of-fit testsources, every 365 daysNovember 21, 2026
Nordheim, Clayton and Yandell, University of Wisconsin Statistics 571, R appendix 13 (2003)sources, every 365 daysNovember 21, 2026
Cochran W.G. (1954). Some methods for strengthening the common chi-square tests. Biometrics 10:417-451sources, every 365 daysNovember 21, 2026
Campbell I. (2007). Chi-squared and Fisher-Irwin tests of two-by-two tables with small sample recommendations. Statistics in Medicine 26:3661-3675sources, every 365 daysNovember 21, 2026
Yates F. (1934). Contingency tables involving small numbers and the chi-square test. Supplement to the Journal of the Royal Statistical Society 1(2):217-235sources, every 365 daysNovember 21, 2026
IBM SPSS Statistics 29 documentation: Crosstabs statisticsreference software, every 180 daysNovember 21, 2026
Cohen J. (1988). Statistical Power Analysis for the Behavioral Sciences, 2nd edition. Lawrence Erlbaum (now Routledge)sources, every 365 daysNovember 21, 2026
APA Style, Numbers and Statistics Guide (7th edition, updated September 2024)style, every 365 daysNovember 21, 2026
DiDonato A.R. and Morris A.H. (1986). Computation of the incomplete gamma function ratios and their inverse. ACM Transactions on Mathematical Software 12(4):377-393sources, every 365 daysNovember 21, 2026

Corrections

If you find a result that disagrees with R, SciPy or a textbook, please tell us through the contact page with the table you used. We check every report and record fixes in the changelog.

Sources