How to find the parameter b such that the following sum of quadratic expressions is minimized?

515 Views Asked by At

Suppose you have $x_1, ..., x_n$. My task is to find $b \in \Bbb{R}$ such that the sum $\sum_{i=1}^n (x_i - b)^2$ is minimal.

Now, I think we can view it as a multivariate function and differentiate...

So how specifically should I proceed?

EDIT:

the $x_i$ were squared by mistake. Anyway, in accordance with JCAA and sven I differentiated and calculated such as the following: $$2b - 2x_1 + 2b - 2x_2 + ... + 2b - 2x_n = 0$$ $$\Rightarrow b = \frac{\sum_{i=1}^n x_i}{n}$$

2

There are 2 best solutions below

1
On BEST ANSWER

If your only task is to find $b$, you may treat the data $x_i$ as being constant, so it is sufficient to differentiate w.r.t. $b$, set the derivative equal to zero, and solve for $b$ in terms of the values $x_i$. In fact, the answer is the mean of the values $x^2_i$ (a special case of squared-error minimization).

1
On

So you want to find a point on the line through 0 parallel to vector $\vec v= (1,.....,1)$ which is the projection of the point $X=(x_1,...,x_n)$ onto that line. This is a standard linear algebra problem. The vector connecting $X$ with point $(b,.....,b)$ must be perpendicular to the vector $\vec v$. Which implies (take the dot product) $\sum x_i=nb$ or $b= \frac{\sum x_i}{n}$.