Proof related to the least squares method

433 Views Asked by At

I've seen this exercise in several statistics text, but how they get to the final formula is something that I don't quite get. How do two squared terms suddenly become a binomial term? I've been trying to figure out how to get to the final formula but I don't get anywhere near. Hope you can help me.

enter image description here

2

There are 2 best solutions below

5
On

One may recall that $$ \bar{x}=\frac1N\cdot \sum_{n=1}^Nx_n $$ giving $$ \begin{align} N^2\cdot \frac1N\sum_{n=1}^N(x_n-\bar{x})^2&=N\sum_{n=1}^N(x_n^2-2x_n\cdot\bar{x}+\bar{x}^2) \\\\&=N\sum_{n=1}^Nx_n^2-2\:N\cdot\bar{x}\sum_{n=1}^Nx_n+N\cdot N\cdot \bar{x}^2 \\\\&=N\sum_{n=1}^Nx_n^2-2\:\left(\sum_{n=1}^Nx_n\right)^2+\left(\sum_{n=1}^Nx_n\right)^2 \\\\&=N\sum_{n=1}^Nx_n^2-\left(\sum_{n=1}^Nx_n\right)^2 \\\\&=\sum_{n=1}^Nx_n^2\cdot\sum_{n=1}^N1-\sum_{n=1}^Nx_n \cdot \sum_{n=1}^Nx_n \\\\&=\det M \end{align} $$ as announced.

0
On

$$\begin{array}{rl} n \|\mathrm x - \bar{x} \, 1_n\|_2^2 &= n (\mathrm x^T \mathrm x - 2 \bar{x} 1_n^T \mathrm x + n \bar{x}^2)\\\\ &= n (\mathrm x^T \mathrm x - 2 n \bar{x}^2 + n \bar{x}^2)\\\\ &= n (\mathrm x^T \mathrm x - n \bar{x}^2)\\\\ &= n \|\mathrm x\|_2^2 - (n \bar{x})^2\\\\ &= n \|\mathrm x\|_2^2 - (1_n^T \mathrm x)^2\end{array}$$