# $\sum_{i = 1}^n (y_i - \mu)^2 = \sum_{i = 1}^n (y_i - \bar{y})^2 + n(\bar{y} - \mu)^2$

I have the following example:

Let $$Y_1, \dots, Y_n$$ be an i.i.d. $$N(\mu, \sigma^2)$$. Note that $$\sum_{i = 1}^n (y_i - \mu)^2 = \sum_{i = 1}^n (y_i - \bar{y})^2 + n(\bar{y} - \mu)^2$$.

We show that $$\sum_{i = 1}^n (Y_i - \bar{Y})^2 \sim \sigma^2 \chi^2_{n - 1}$$.

By the equality

$$\dfrac{1}{\sigma^2} \sum_{i = 1}^n (Y_i - \mu)^2 = \dfrac{1}{\sigma^2} \sum_{i = 1}^n (Y_i - \bar{Y})^2 + \dfrac{1}{\sigma^2} n(\bar{Y} - \mu)^2,$$

we have that the left-hand side is

$$\dfrac{1}{\sigma^2} \sum_{i = 1}^n (Y_i - \mu)^2 \sim \chi_n^2,$$

and the term in the right-hand side is

$$\dfrac{1}{\sigma^2} n(\bar{Y} - \mu)^2 \sim \chi_1^2,$$

and so $$\dfrac{1}{\sigma^2} \sum_{i = 1}^n (Y_i - \bar{Y})^2 \sim \chi_{n - 1}^2$$

How did the author conclude that $$\sum_{i = 1}^n (y_i - \mu)^2 = \sum_{i = 1}^n (y_i - \bar{y})^2 + n(\bar{y} - \mu)^2$$?

It can be shown via variable addition and subtraction: \begin{align}\sum (y_i-\mu)^2&=\sum(y_i-\bar y +\bar y -\mu)^2\\&=\sum(y_i-\bar y)^2+\sum(\bar y-\mu)^2 + \sum2(y_i-\bar y)(\bar y - \mu)\\&=\sum(y_i-\bar y)^2+n(\bar y-\mu)^2 + 2(\bar y - \mu)\underbrace{\sum(y_i-\bar y)}_0\\&=\sum(y_i-\bar y)^2+n(\bar y-\mu)^2\end{align}
• Thanks for the answer. What property is $\sum(y_i-\bar y +\bar y -\mu)^2 = \sum(y_i-\bar y)^2+\sum(\bar y-\mu)^2 + \sum2(y_i-\bar y)(\bar y - \mu)$? Commented Mar 14, 2020 at 19:46
• $$(a+b)^2=a^2+b^2+2ab$$ Commented Mar 14, 2020 at 19:46
• Thanks! And how do we know that $2(\bar y - \mu)\underbrace{\sum(y_i-\bar y)}_0$? Commented Mar 14, 2020 at 19:48
• $\sum (y_i-\bar y)=\sum y_i - \sum \bar y = n\bar y - n\bar y = 0$ Commented Mar 14, 2020 at 19:48
• Ahh, yes: The equation of the sample mean is $\bar{X} = \dfrac{1}{n} \sum_{j = 1}^n X_j$. Commented Mar 14, 2020 at 19:51