Pearson chi-squared goodness-of-fit test (source code)

= Pearson chi-squared goodness-of-fit test
{c}

For observed cell counts $O_j$ and null expected counts $E_j$, the statistic is
$$
X^2=\sum_j\frac{(O_j-E_j)^2}{E_j}.
$$
With $k$ specified null cell probabilities and sufficiently large expected counts, its null limit is $\chi^2_{k-1}$.