On plane $OXY$ find point $P(x,y)$, for which sum of squared distances to given points $P_{i}(x_i,y_i)$, $i=1,2,...,n$ is the smallest possible.
- 507
-
1Commenting here so that I can find later. Interested in answer also. – 123 Sep 07 '17 at 17:44
-
@123 use the "star" button just under the upvote triangle. – Zach Teitler Sep 08 '17 at 00:31
1 Answers
Assuming that the $(x,y)$ are cartesian coordinates (your minimalist question and useless title are unclear), this is a simple optimization problem. You are looking for the values of $x$ and $y$ which minimize the sum $$\sum_{i=1}^n (x-x_i)^2 + (y-y_i)^2$$ Note that we can break the sum in two with the first half depending only on $x$ and the second half depending only on $y$. If we minimize the two halves separately, it will minimize the whole as well.
So it is just a matter of finding the value of $x$ which minimizes $f(x) =\sum_{i=1}^n (x-x_i)^2$. Setting the derivative to zero, the minimum will occur when $$2\sum_{i=1}^n (x-x_i) = 0$$ or $$x =\frac {\sum_{i=1}^n x_i}n$$ I.e., when $x$ is the average of $x_i$. Similarly the second half is minimized when $y$ is the average of the $y_i$:
$$(x,y) =\left(\frac {\sum_{i=1}^n x_i}n,\frac {\sum_{i=1}^n y_i}n\right)$$
- 43,643