Statistics & graphs · SL/HL

Chi-squared test

Compare observed counts with expected counts.

Your values

Number formats & units

Use decimal dots in datasets. Single values also accept decimal commas and scientific notation such as 1.2e-3 or 1.2 × 10⁻³.

Chi-Squared Test Calculator inputs

Calculated locally. No account or input upload.

Result & working

Example

The calculator is loading. The worked example is also shown below.

Copy & export

Formula & example

The relationship

χ2=∑i(Oi−Ei)2Ei\chi^2=\sum_i\frac{(O_i-E_i)^2}{E_i}
df=categories−1(goodness of fit)\mathrm{df}=\text{categories}-1\quad\text{(goodness of fit)}
Eij=row totali×column totaljgrand totalE_{ij}=\frac{\text{row total}_i\times\text{column total}_j}{\text{grand total}}df=1(2×2 association)\mathrm{df}=1\quad\text{(2×2 association)}
What the variables mean
SymbolMeaning
OOObserved frequency.
EEExpected frequency under the null model.

Worked example

Test type
Goodness of fit
Observed values
315 108 101 32
Expected values
312.75 104.25 104.25 34.75

χ² = 0.470024, p = 0.92543

Follow the example steps
  1. Category 1: (O−E)²/E = (315−312.75)²/312.75 = 0.01618705
  2. Category 2: (O−E)²/E = (108−104.25)²/104.25 = 0.1348921
  3. Category 3: (O−E)²/E = (101−104.25)²/104.25 = 0.1013189
  4. Category 4: (O−E)²/E = (32−34.75)²/34.75 = 0.2176259
  5. Observed total = 556; expected total = 556.
  6. χ² = 0.470024; df = 3
  7. Right-tail p ≈ 0.92543.

Common mistakes

Divide each squared deviation by its expected count.

Incorrect approach

O = 20, E = 10: (O − E)²/O = 5

Correct approach

(O − E)²/E = 10

More checks before you submit
  • Frequencies must be counts, not percentages with an arbitrary total.
  • Very small expected counts can make the usual chi-squared approximation unreliable.
Method notes

In the current Biology syllabus, chi-squared is used in contexts including species association and genetic ratios.