Say I have n points on a plane which are not collinear. What's the most efficient way to translate each point so that all points are collinear? I want to minimize the sum of the distances traveled.
I'm guessing that taking a linear regression using https://en.wikipedia.org/wiki/Least_absolute_deviations and then moving each point to the line along a perpendicular path is at least a close approximation. Is that the optimal solution though? I'm worried that it may be inaccurate since LAD seems to focus on the y-axis rather than my "distance traveled" metric.
I feel like this must be a solved problem, but maybe I don't have a good enough vocabulary to search for it. No urgency here, I'm just curious.
Edit: an interesting variation is minimizing the max distance, i.e. how does a crowd of people line up ASAP if they're all equally speedy.
For any fixed direction of line, the maximum distance is minimized by placing the line midway between the two antipodal points on the convex hull of the point set. The corresponding distance is half the width of the convex hull in the direction perpendicular to the line. Therefore, the problem is equivalent to finding the direction in which the convex hull has minimum width, and can be solved using the rotating calipers algorithm.
Minimizing the total distance is likely to be harder: if you replace the unknown line with an unknown point, this is the problem of finding the geometric median, which does not have an analytical solution or a direct algorithm. However, an iteratively reweighted least-squares approach may work. Using the notation of the linked article, let $\beta$ be the unknown line and $f_i(\beta)$ the projection of the $i$th point $y_i$ onto it, so that you want to minimize $\sum\|y_i-f_i(\beta)\|$. Iteratively reweighted least-squares will require you to solve subproblems of the form $$\beta^{(t+1)}={\arg\min}_\beta\sum w_i^{(t)}\|y_i-f_i(\beta)\|^2$$ instead, where $w_i^{(t)}=\|y_i-f_i(\beta^{(t)})\|^{-1}$. This you can do using an eigendecomposition, as described in orangeskid's answer (albeit slightly modified to account for the weights $w_i^{(t)})$.