Chi Square Test Calculator
This chi square test calculator checks whether two variables are related (test of independence) or whether counts match an expected distribution. Enter your table; the 2 × 2 example 30/20 and 15/35 gives χ² = 9.09 and p = 0.0026.
Source: 1.3.6.6.6, NIST/SEMATECH e-Handbook – Chi-square distribution. Updated: .
How it is calculated
The chi-square test compares observed with expected counts. As a test of independence it shows whether two variables (such as gender and product choice) are related; as a goodness-of-fit test it checks whether a distribution matches a given one (for example whether a die is fair).
How the test works
- Expected count per cell: E = row total · column total / grand total (independence) or n · expected proportion (goodness of fit).
- Test statistic: χ² = Σ (O − E)² / E, summed over all cells.
- Degrees of freedom: (rows − 1) · (columns − 1), or categories − 1.
- p-value: the probability of a χ² this large by chance if the null hypothesis is true. If p is below α (usually 5%), the result is significant.
Example
Of 50 people in group A, 30 buy; of 50 in group B only 15. The expected counts are 22.5 and 27.5. χ² = 9.09 with 1 degree of freedom, p = 0.0026 – the difference is significant. Cramér's V = 0.30 shows a moderate association.
Assumptions and limits
- Use absolute counts (not percentages), and each person may appear only once.
- Most expected counts should be at least 5. Otherwise merge categories, or for 2 × 2 use Fisher's exact test.
- The Yates correction (2 × 2 only) shrinks χ² a little and is conservative; both values are shown.
- A significant test says nothing about cause or size: use Cramér's V and the residuals (absolute values above about 2 mark the notable cells).
Frequently asked questions
How do you calculate a chi-square test?
First find the expected counts (row total · column total / grand total), then compute (O − E)² / E for each cell and add them up. The resulting χ² is turned into a p-value with the chi-square distribution (degrees of freedom = (rows − 1) · (columns − 1)).
What does the p-value mean in a chi-square test?
It is how likely a difference between observed and expected counts at least this large would be if there were really no association. A p below the level α (for example 0.05) speaks against the null hypothesis.
When do you use the Yates correction?
For a 2 × 2 table with small counts. It subtracts 0.5 from each distance |O − E| and makes the test more cautious. With large samples the difference is small.
What is Cramér’s V?
A measure of the strength of association between 0 (none) and 1 (complete): V = √(χ² / (n · min(rows − 1, columns − 1))). As a rule of thumb for 2 × 2: 0.1 weak, 0.3 moderate, 0.5 strong.
What if expected counts are below 5?
Merge neighbouring categories or collect more data. For a 2 × 2 table Fisher’s exact test is the better choice.
Sources and legal basis
- 1.3.6.6.6: NIST/SEMATECH e-Handbook – Chi-square distribution
- 1.3.5.15: NIST/SEMATECH e-Handbook – Chi-square goodness-of-fit test
- Wikipedia – Cramér’s V
As of: · Editorial policy
Related tools
- Punnett square calculator with genotype and phenotype ratiosPunnett square calculator for monohybrid, dihybrid and trihybrid crosses: enter both parents (e.g. AaBb) and get gametes, grid and genotype/phenotype ratios.
- Hardy Weinberg calculator for allele and genotype frequenciesHardy Weinberg calculator: allele frequencies p and q from genotype counts, from the share of recessive individuals (q²) or from p, plus p², 2pq and q².
- P-Value CalculatorP-value calculator from a z-score, t-score or chi-square, or straight from a t-test with means, SDs and n – plus critical value and confidence interval.
- Standard deviation calculatorStandard deviation calculator for a list or frequency table: switch between sample (s) and population (σ), see every step in a table, plus a box plot.
- Correlation Coefficient CalculatorCorrelation coefficient calculator for paired data: Pearson r and Spearman ρ with p-value, confidence interval, R² and regression line. Paste a table.
- Probability calculatorProbability calculator: favourable over possible outcomes, two events, repeated trials (binomial) and drawing without replacement, like a lottery.
- Online CalculatorCalculator online, free and instant: type or tap and see the answer as you go – order of operations, brackets, percent, square root, steps and a history list.
- Easy grader for teachersEasy grader for teachers: enter the number of questions and how many were wrong to get the percentage and letter grade, plus a full grading chart to print.
- Pneumatic cylinder force calculator with load factor and air consumptionPneumatic cylinder force calculator: extend and retract force from bore, rod and pressure, usable load with SMC load factor, minimum bore and air consumption.