# Difference of means of Binomial variables

If the formula for a hypothesis test is

$$z = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{\frac{\sigma^2_{x_1}}{n_{x_1}} + \frac{\sigma^2_{x_2}}{n_{x_2}}}}$$

And the variance for a binomial variable is given by the equation

$$\sigma^2 = np(1-p)$$

Then why is the sum of the variances given by

$$\sigma_{x_1 - x_2} = \sqrt{\frac{p_1(1-p_1)}{n_{x_1}} + \frac{p_2(1-p_2)}{n_{x_2}}}$$

Rather than

$$\sigma_{x_1 - x_2} = \sqrt{p_1(1-p_1)+ p_2(1-p_2)}$$

• When you divide a random variable by $n$ you divide its variance by $n^2$ Commented Oct 3, 2016 at 4:16

The correct formulas are $$\text{st.dev}\left(\frac{x_1}{n_{x_1}}+\frac{x_2}{n_{x_2}}\right)=\sqrt{\frac{p_1(1-p_1)}{n_{x_1}}+\frac{p_2(1-p_2)}{n_{x_2}}}$$ and $$\text{st.dev}\left(x_1+x_2\right)=\sqrt{p_1(1-p_1)+p_2(1-p_2)}.$$ Let me derive the first formula: $$\text{st.dev}\left(\frac{x_1}{n_{x_1}}+\frac{x_2}{n_{x_2}}\right)=\sqrt{\text{var}\left(\frac{x_1}{n_{x_1}}\right)+\text{var}\left(\frac{x_2}{n_{x_2}}\right)}$$ and because $$\text{var}\left(\frac{x}{n_{x}}\right)=\frac{1}{n^2}\text{var}\left(x\right)=\frac{p(1-p)}{n}$$ you get the first formula.

• I don't follow what you did. For a binomial random variable the Var(x) = np(1-p). Where does var(x1/nx1) come from? Commented Oct 2, 2016 at 21:12
• @hot_whiskey I am not sure what you are asking; perhaps you didn't see the step var(X/n-Y/n)=var(X/n)+var(Y/n)? Or perhaps you did not recognize that your 'correct' formula(your 3rd) is wrong if sigma_(x1-x2) is notation for the standard deviation of x1-x2 Commented Oct 2, 2016 at 21:27
• Sorry, I don't mean to be obtuse. I don't understand the st.dev() notation, and I don't understand why the first formula you give doesn't have an n in front of p1 and p2, where everywhere I have read gives the variance equation as σ2=np(1−p). onlinecourses.science.psu.edu/stat414/node/71. Then, in the third equation what are you taking the variance of? Commented Oct 2, 2016 at 21:59