Line closest to a set of points [duplicate]

2020-07-11 07:36发布

Given a set of points S (x, y).

Find the line whose distance from all the points is minimum ? That is, minimize the sum of distances (in absolute value or squared) between each point and the optimal line.

By distance I mean the shortest distance between the point and the line. That is, the most common one, the euclidean distance in euclidean space.

I tried googling but could not find any relevant results, is there any line sweep algorithm that can do the task?

1条回答
时光不老,我们不散
2楼-- · 2020-07-11 08:13

I suppose you are trying to fit a curve/line, thus I would suggest least squares fitting for your case.

You can have a look at: http://www.alglib.net/interpolation/leastsquares.php

Hope it helps. :-)

查看更多
登录 后发表回答