[Math] How to find a line that minimizes the average squared perpendicular distance from the given points to the line

data analysisleast squaresoptimizationvectors

I have set of points scattered around the origin. How to find a vector, such that the average squared distance (perpendicular distance) from points to the vector is minimised?

Added

For example, let the dimension be 2. So a vector can be written (from the origin) as $(a_1,a_2)$. Now take a point $(x_1, x_2)$. Drop a perpendicular line from the point to the vector and I want to find the length of that line segment.

Best Answer

If I well understand the question, this is the problem of fitting with perpendicular offsets.

In case of 2D. : http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html

In case of 3D. , see pages 2-12 in section "3D Linear Regression" of the paper : http://fr.scribd.com/doc/31477970/Regressions-et-trajectoires-3D