# Chi-Square Test for Compatibility of K Counts

Tests the null hypothesis that all $\displaystyle{ s }$ categories of a categorical variable, $\displaystyle{ x }$, are the same size. The test statistic is
$\displaystyle{ X^2 = \sum^s_{k=1} \frac{(o_{kj} - e_{kj})^2}{e_{kj}} }$
$\displaystyle{ o_{k} = \sum^n_{i=1} w_i I_{x=k} }$,
$\displaystyle{ w_i }$ is the Calibrated Weight of the $\displaystyle{ i }$th of $\displaystyle{ n }$ observations,
$\displaystyle{ e_{k} = \frac{ \sum^n_{i=1} w_i}{s} }$
$\displaystyle{ p \approx \Pr(\chi^2_{(s-1)} \ge X^2) }$