Chi-Square Test Calculator
Free online chi-square (χ²) calculator. Compute the chi-square statistic, degrees of freedom and p-value for goodness of fit tests and tests of independence, with automatic significance conclusions.
What is the Chi-Square Test?
The chi-square (χ²) test is a statistical method that compares observed frequencies with expected frequencies to decide whether differences are due to chance or reflect a real pattern. The larger the χ² value, the more the observed data deviate from what the null hypothesis predicts.
A goodness of fit test checks whether observed counts follow a hypothesized distribution. A test of independence checks whether two categorical variables are associated, e.g. whether gender and product preference are related.
The p-value tells you the probability of seeing a χ² value at least this large if the null hypothesis were true. A small p-value (typically p < 0.05) suggests the observed pattern is unlikely to be pure chance.
Chi-Square Formula
For each cell, the chi-square statistic is the sum of squared differences between observed (O) and expected (E) counts, divided by the expected count:
χ² = Σ (O − E)² / E
df = k − 1 (goodness of fit) / df = (r − 1)(c − 1) (independence)
How to Use This Calculator
Follow these steps:
- Choose the test type: goodness of fit (one categorical variable) or test of independence (a contingency table of two variables).
- Enter the observed counts — as a list for goodness of fit, or in the row × column grid for independence.
- For goodness of fit you may enter expected counts; if left blank, equal expected counts are assumed.
- Read the χ² statistic, degrees of freedom, p-value and significance conclusion, plus the expected counts table.
Worked Example
A coin is tossed 100 times: 44 heads and 56 tails. Does the coin appear fair?
Frequently Asked Questions
Have another question? Let us know.
What is the difference between a goodness of fit test and a test of independence?
A goodness of fit test compares observed counts for a single categorical variable against a hypothesized distribution (e.g. a fair die). A test of independence uses a contingency table to ask whether two categorical variables are related (e.g. gender and voting preference).
When should I not use the chi-square test?
The chi-square test assumes each observation is independent and expected counts are not too small. A common rule of thumb is that no more than 20% of cells should have an expected count below 5, and all expected counts should be at least 1. For small samples, consider Fisher's exact test.
How do I compute the degrees of freedom?
For a goodness of fit test, df = k − 1 where k is the number of categories. For a test of independence, df = (r − 1) × (c − 1) where r is the number of rows and c is the number of columns.
Can the chi-square test tell me the strength of an association?
No. The chi-square test only tells you whether an association is statistically significant. To measure the strength of the association, use effect sizes such as Cramér's V or the phi coefficient.
Related Resources
- P-Value Calculator — turn χ² into a p-value
- Z-Score Table — standardize scores and read tables
- Correlation Calculator — for continuous instead of categorical data
- Descriptive Statistics Calculator — summarize your counts first
- Chi-Square Test — definition, formula and worked example
- Experimental Design — where categorical outcomes come from
