User Rating 0.0
Total Usage 0 times
2 – 30
Category Observed (O) Expected (E)
Is this tool helpful?

Your feedback helps us improve.

About

Incorrect application of the chi-square test leads to false conclusions in clinical trials, market research, and quality control. A miscalculated p-value can approve a defective product batch or reject a viable drug candidate. This calculator computes the Pearson chi-square statistic χ2 = (O E)2E using the regularized incomplete gamma function for exact p-value derivation rather than table lookup. It supports both goodness-of-fit tests (one-dimensional frequency comparison against a theoretical distribution) and tests of independence on r × c contingency tables up to 10 × 10. Effect size is reported via Cramér’s V.

The test assumes observations are independent, categories are mutually exclusive, and all expected frequencies exceed 5. When expected counts fall below this threshold, results become unreliable and Fisher’s exact test should be considered instead. Degrees of freedom are computed automatically: (r 1)(c 1) for independence, (k 1) for goodness-of-fit. Pro tip: always verify that your sampling method produces genuinely independent observations before trusting the output.

chi-square chi-square calculator statistics p-value hypothesis testing goodness of fit independence test contingency table cramers v degrees of freedom

Formulas

The Pearson chi-square statistic measures the discrepancy between observed and expected frequencies across k categories:

χ2 = ki=1 (Oi Ei)2Ei

Where Oi = observed frequency in category i, and Ei = expected frequency in category i.

For a test of independence on an r × c contingency table, expected frequencies are computed as:

Eij = Ri CjN

Where Ri = total of row i, Cj = total of column j, N = grand total of all observations.

Degrees of freedom:

df = (r 1)(c 1) (independence)
df = k 1 (goodness-of-fit)

The p-value is obtained from the upper tail of the chi-square distribution using the regularized upper incomplete gamma function:

p = Q(df2, χ22) = 1 P(df2, χ22)

Cramér’s V measures effect size for independence tests:

V = χ2N min(r 1, c 1)

Where V ranges from 0 (no association) to 1 (perfect association). Values below 0.1 indicate negligible effect, 0.1 - 0.3 small, 0.3 - 0.5 medium, and above 0.5 large effect.

Reference Data

Degrees of Freedom (df)α = 0.10α = 0.05α = 0.025α = 0.01α = 0.005α = 0.001
12.7063.8415.0246.6357.87910.828
24.6055.9917.3789.21010.59713.816
36.2517.8159.34811.34512.83816.266
47.7799.48811.14313.27714.86018.467
59.23611.07012.83315.08616.75020.515
610.64512.59214.44916.81218.54822.458
712.01714.06716.01318.47520.27824.322
813.36215.50717.53520.09021.95526.124
914.68416.91919.02321.66623.58927.877
1015.98718.30720.48323.20925.18829.588
1218.54921.02623.33726.21728.30032.909
1522.30724.99627.48830.57832.80137.697
2028.41231.41034.17037.56639.99745.315
2534.38237.65240.64644.31446.92852.620
3040.25643.77346.97950.89253.67259.703
4051.80555.75859.34263.69166.76673.402
5063.16767.50571.42076.15479.49086.661
6074.39779.08283.29888.37991.95299.607
8096.578101.879106.629112.329116.321124.839
100118.498124.342129.561135.807140.169149.449

Frequently Asked Questions

Use the goodness-of-fit test when you have a single categorical variable and want to compare observed frequencies against a known or hypothesized distribution (e.g., testing whether a die is fair). Use the test of independence when you have two categorical variables arranged in a contingency table and want to determine whether they are statistically associated (e.g., whether treatment type affects recovery outcome).
The chi-square approximation becomes unreliable when any expected cell count falls below 5. The calculator flags such cells with a warning. In these cases, consider combining categories to increase expected counts, or use Fisher's exact test for 2×2 tables. For larger sparse tables, a Monte Carlo simulation of the exact distribution is preferable.
The p-value is computed algorithmically using the regularized incomplete gamma function. Specifically, p = Q(a, x) where a = df ÷ 2 and x = χ2 ÷ 2. The implementation uses a series expansion for small x and Lentz's continued fraction algorithm for large x, achieving precision to approximately 10 significant digits.
No. Cramér's V is mathematically bounded between 0 and 1. A value of 0 indicates complete independence between variables. A value of 1 indicates a perfect deterministic relationship. It cannot be negative because it is derived from a square root of a ratio of non-negative quantities.
Yates' correction subtracts 0.5 from each absolute observed-minus-expected difference before squaring, reducing the chi-square value for 2×2 tables. This compensates for the discrete-to-continuous approximation. It is most relevant when sample sizes are small (total N < 40). For large samples, the correction has negligible effect. This calculator applies Yates' correction automatically for 2×2 independence tables and displays both corrected and uncorrected values.
Higher degrees of freedom shift the chi-square distribution to the right, increasing the critical value needed to reject the null hypothesis at a given significance level. For example, at α = 0.05, the critical value is 3.841 for df = 1 but 18.307 for df = 10. The reference table above provides critical values for common df and α combinations.