# Why are there 2 variance formulas equal?

I have found two separate definitions for variance, listed below. Could you please explain why they are equivalent?

i) Variance of y $= \displaystyle \sum_{i=1}^n p_i(y_i - \mu)^2$

ii) Variance of y $= \displaystyle \left(\sum_{i=1}^n p_i y_i^2\right) - \mu^2$

• sum_{i=1}^{n} is supposed to be sigma notation with i=1,2....n – user95087 Sep 16 '13 at 3:16
• – user61527 Sep 16 '13 at 3:17
• Hint: $(a-b)^2 = a^2 + b^2 - 2ab$ and $\mu_y = \sum_i p_iy_i$. – Dilip Sarwate Sep 16 '13 at 3:24
• I expanded the first equation but I cannot get it to look like the second one. – user95087 Sep 16 '13 at 3:35
• We must have seen this question a few times before. – Michael Hardy Sep 16 '13 at 4:03

\begin{align} \sum_{i=1}^n p_i(y_i - \mu)^2 & = \sum_i p_i(y_i^2 - 2 \mu y_i + \mu^2) \\[12pt] & = \left(\sum_i p_i y_i^2\right) -2\mu\left(\sum_i p_i y_i\right) + n\mu^2 \\[12pt] & = \left(\sum_i p_i y_i^2\right) -2\mu(n\mu) + n \mu^2 \end{align} Now do some routine algebraic simplifications.
• How come $p_i$ did not distribute to 2$uy_i$? – user95087 Sep 16 '13 at 13:21
• Typo. Fixed. ${{{}}}$ – Michael Hardy Sep 16 '13 at 17:53