About this chi-square calculator
χ² = Σ (observed − expected)² ÷ expected. Goodness of fit compares one row of counts with expected counts: a die rolled 120 times landing 22, 17, 20, 26, 22, 13 gives χ² = 5.1 with 5 degrees of freedom, p = 0.404, no evidence the die is unfair. For independence, expected = row total × column total ÷ grand total: the table 20, 30 / 30, 20 gives χ² = 4, df = 1, p = 0.0455, significant at 0.05.