Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line closest to a set of points [duplicate]

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?

like image 397
Ninja420 Avatar asked Sep 08 '13 02:09

Ninja420


1 Answers

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. :-)

like image 77
ChangeMyName Avatar answered Oct 14 '22 13:10

ChangeMyName