# How to prove this decomposition of sum of squares?

I am reading a paper "A Compendium of Conjugate Priors" by Daniel Fink (Published May 1997).

It has a mathematical step shown as

$$\sum_{i=1}^{n}(x_i-\mu)^2=n(\mu-\overline x)+\sum_{i=1}^n(x_i-\overline x)^2$$

Here the $\mu$ is unknown parameter and $\overline x$ is the known mean of $\mathbf x=(x_1, x_2, x_3, \dots,x_n)$

How do I demonstrate this identity?

• Your formula contains an error. Feb 1, 2017 at 12:20
• The exact formula is called Pythagoras's theorem... Feb 1, 2017 at 22:05

I am afraid that the statement you show is wrong. Adding and subtracting $\bar{x}$:

$$\sum_{i=1}^{n}(x_i-\mu)^2=\sum_{i=1}^{n}((x_i-\bar{x})-(\mu-\bar{x}))^2$$

Powering $(a-b)^2=a^2-2ab+b^2$: $$=\sum_{i=1}^{n}\left((x_i-\bar{x})^2-2(x_i-\bar{x})(\mu-\bar{x})+(\mu-\bar{x})^2\right)$$ Rearagning the sums $$=\sum_{i=1}^{n}(x_i-\bar{x})^2-\sum_{i=1}^{n}2(x_i-\bar{x})(\mu-\bar{x})+\sum_{i=1}^{n}(\mu-\bar{x})^2$$ Last sum does not depend on index $i$ $$=\sum_{i=1}^{n}(x_i-\bar{x})^2-\sum_{i=1}^{n}2(x_i-\bar{x})(\mu-\bar{x})+n(\mu-\bar{x})^2$$ Putting out things from the second sum that are independent on $i$ $$=\sum_{i=1}^{n}(x_i-\bar{x})^2-2(\mu-\bar{x})\sum_{i=1}^{n}(x_i-\bar{x})+n(\mu-\bar{x})^2$$

Let us focus on $\sum_{i=1}^n(x_i-\bar{x})=\sum_{i=1}^n x_i-n\bar{x}=\frac{n}{n}\sum_{i=1}^n x_i-n\bar{x}=n\bar{x}-n\bar{x}=0$

Thus, $$\sum_{i=1}^{n}(x_i-\mu)^2 = \sum_{i=1}^{n}(x_i-\bar{x})^2+n(\mu-\bar{x})^2$$

Your formula is wrong as it misses the power in the second term.

I see while I was writing this @KarelMacek (+1) gave a identical proof.

\begin{align} &\sum_{i=1}^{n}(x_i-\mu)^2= \\ &\sum_{i=1}^{n}x_i^2-2\sum_{i=1}^{n}x_i\mu+\sum_{i=1}^{n}\mu^2=\\ &\sum_{i=1}^{n}x_i^2-2\mu\left(\sum_{i=1}^{n}x_i\right)+n\mu^2=\\ &\sum_{i=1}^{n}x_i^2-2\mu n\overline x+n\mu^2=\\ &\sum_{i=1}^{n}(x_i-\overline x)^2+2\overline x\sum_{i=1}^{n}x_i+\sum_{i=1}^{n}\overline x^2-2\mu n\overline x+n\mu^2=\\ &\sum_{i=1}^{n}(x_i-\overline x)^2+2 n \overline x ^2-n\overline x^2-2\mu n\overline x+n\mu^2=\\ &\sum_{i=1}^{n}(x_i-\overline x)^2+ n \left(\overline x ^2-2\mu \overline x+\mu^2\right)\\ &\therefore \sum_{i=1}^{n}(x_i-\mu)^2=\sum_{i=1}^{n}(x_i-\overline x)^2+ n \left(\overline x -\mu\right)^2 \end{align}

Which is clearly not what Fink stated.