# Power of the $\chi^2$ test constraint?

I understand that the distribution of the $\chi^2$ goodness of fit test ($\sum\dfrac{(x_i-m_i)^2}{m_i}$) is a non-central chi-squared with non centrality parameter $\lambda=\sum\dfrac{(m_i-m'_i)^2}{m'_i}$, where $m_i$ are the expectations under $H_0$ and $m'_i$ are the expectations under $H_1$. What I'm having trouble understanding is what is the role of the constraint $\sum(x_i-m'_i)=0$?

• What is $x_i$? Should $p_1$ be $p_i$? – user158565 May 8 '17 at 1:43
• @a_statistician, I edited my question. $x_i$ are the sample, they have a Binomial distribution with different probabilities. – Enthusiastic May 8 '17 at 9:31
• So you can understand $\sum(x_i - m_i) = 0$ and cannot understand $\sum(x_i - m'_i) = 0$? They follow the same idea. – user158565 May 8 '17 at 16:23
• @a_statistician, I don't understand why either of them have to be zero. – Enthusiastic May 8 '17 at 16:35

Suppose there are 3 groups and $x_1 = 30$, $x_2 = 20$ and $x_3=50$. $N=30+20+50 = 100$. Suppose under $H_0$: the probabilities for 3 groups are 0.3, 0.2 and 0.5.
Obviously, the observed counts are totally agree with $H_0$. If we distribute 100 subjects into 3 groups according to their probabilities, we will get $\chi^2 = 0$.
But if we distribute 10,000 subjects into 3 groups according to their probabilities, we will get a large $\chi^2$ value. And it is not what we wanted.
The goodness of fit chi-square test is a kind of test conditional on the total number of observed subjects. After observing $N$ subjects, we will distributed $N$ subjects according to probabilities derived from hypothesis. If observed frequencies are closed to expected frequencies, the hypothesis is reasonable; otherwise the hypothesis may be wrong.