# What value of $\alpha$ makes $\sum_{i=0}^n (x_i-\alpha)^2$ minimal?

I know that $\bar{x}$ makes absolute result of $\sum_{i=0}^n (x_i-\alpha)$ minimum. In fact it makes it zero. But how to find what value of $\alpha$ makes $\sum_{i=0}^n (x_i-\alpha)^2$ minimal? What is the best approach?

• By "the absolute result of $\sum (x_i-\alpha)$", do you mean $|\sum (x_i-\alpha)|$? – Glen_b Oct 11 '15 at 9:23
• Since $\sum (x_i-\alpha)= 0$ when $\alpha=\bar{x}$, you're correct that this value for $\alpha$ minimizes $|\sum (x_i-\alpha)|$. As to the question of what value for $\alpha$ minimizes $\sum (x_i-\alpha)^2$, this can be achieved in several ways, such as by simple calculus, or by writing $\sum (x_i-\alpha)^2=\sum (x_i-\bar{x}+\bar{x}-\alpha)^2$ and then expanding and simplifying. I think the first approach is covered in a number of questions already on our site; the second approach may be as well. I'll see if I can find some links – Glen_b Oct 11 '15 at 9:39
• I found some posts that related to those two solutions, but nothing quite close enough to really call a duplicate. I'll outline one approach. – Glen_b Oct 11 '15 at 11:05
• As an interesting aside, the median minimizes the sum of the absolute deviations:$|x_i-\alpha|$ – user75138 Oct 11 '15 at 12:26
• As stated in this answer, It is well-known (or easily proved) that the quadratic $\alpha z^2 + 2\beta z + \gamma$ has an extremum at $z = -\frac{\beta}{\alpha}$. This shows that, for any given $n$ real numbers $x_1, x_2, \ldots, x_n$, the quantity $$G(a) = \sum_{i=1}^n (x_i-a)^2 = \left(\sum_{i=1}^n x_i^2\right)-2a\left(\sum_{i=1}^n x_i\right) + na^2,$$ has minimum value when $\displaystyle a = \frac 1n \sum_{i=1}^n x_i =\bar{x}$. – Dilip Sarwate Oct 11 '15 at 14:32

As I mentioned in comments, showing what minimizes $\sum (x_i-\alpha)^2$ can be done in several ways, such as by simple calculus, or by writing $\sum (x_i-\alpha)^2=\sum (x_i-\bar{x}+\bar{x}-\alpha)^2$. Let's look at the second one:
$\sum (x_i-\alpha)^2=\sum (x_i-\bar{x}+\bar{x}-\alpha)^2$ $\hspace{2.55cm}=\sum (x_i-\bar{x})^2+\sum(\bar{x}-\alpha)^2+2\sum(x_i-\bar{x})(\bar{x}-\alpha)$ $\hspace{2.55cm}=\sum (x_i-\bar{x})^2+\sum(\bar{x}-\alpha)^2+2(\bar{x}-\alpha)\sum(x_i-\bar{x})$ $\hspace{2.55cm}=\sum (x_i-\bar{x})^2+\sum(\bar{x}-\alpha)^2+2(\bar{x}-\alpha)\cdot 0$ $\hspace{2.55cm}=\sum (x_i-\bar{x})^2+\sum(\bar{x}-\alpha)^2$
Now the first term is unaltered by the choice of $\alpha$ and the last term can be made zero by setting $\alpha=\bar{x}$; any other choice leads to a larger value of the second term. Hence that expression is minimized by setting $\alpha=\bar{x}$.
Putting the first derivative (with respect to $\alpha$) equal to zero you find $2\sum_i (x_i -\alpha) (-1) = 0$ so $\sum_i x_i = n \alpha$ or $\alpha = \frac{1}{n} \sum_i x_i$