The previous post considered
the problem of finding the line that best fits a set of points in the plane,
with the additional restriction that the points' center of mass was at the origin.
This post will consider points without any restrictions, but the line, however,
must pass through the origin.
Let the points be given as (xi,yi) for i=1,…,n, where n≥1
is the number of points.
We will furthermore require that not all xi are equal to zero or,
equivalently, that ∑i=1nxi2>0.
Again, we will look for a least squares definition of best.
So we seek a line y=ax that minimizes the following error function:
J=i=1∑n(axi−yi)2.
To find the stationary point of J, we set the partial derivative with respect to a to zero: