7
$\begingroup$

I need to find the line having minimal distance to all points. I found linear regression and linear interpolation algorithms. But their minimal distance is only in y-axis: $D = y - f(x)$.

But I need to find $a,b,c$ for line: $ax + by + c = 0$ where distance is computed this way: $D_i = \dfrac{|ax_i + by_i + c|}{\sqrt{a^2+b^2}}$

Is there any way or algorithm to solve this problem?

$\endgroup$
2
  • $\begingroup$ So all your points are in 2D? $\endgroup$
    – Jacob
    Commented Sep 23, 2011 at 14:55
  • $\begingroup$ Yes. They are in 2D. $\endgroup$
    – kravemir
    Commented Sep 23, 2011 at 14:56

1 Answer 1

4
$\begingroup$

What you want to do is called total least squares or orthogonal regression. Netlib has a bunch of routines for doing this, and a bit of searching turns up routines for other systems, e.g. MATLAB.

$\endgroup$
5
  • $\begingroup$ Thanks :) This seems to be i want to do. $\endgroup$
    – kravemir
    Commented Sep 23, 2011 at 14:48
  • $\begingroup$ Someone posted comment about en.wikipedia.org/wiki/Principal_component_analysis. Is there any difference with your post? $\endgroup$
    – kravemir
    Commented Sep 23, 2011 at 14:50
  • $\begingroup$ Certainly, one in fact uses SVD (the machinery behind PCA) for total least squares. See this for instance. $\endgroup$ Commented Sep 23, 2011 at 14:58
  • $\begingroup$ @Miro: I posted that comment, but deleted it after I saw J.M.'s answer. J.M.: Boy, doesn't SVD on covariance-like matrices turn up everywhere? From PCA to principal axes of inertia to ellipsoids to this question. I posted the first related thing that came to my head, but it's nice to know it has a specific name in this particular application. $\endgroup$
    – user856
    Commented Sep 23, 2011 at 15:07
  • $\begingroup$ @Rahul: SVD is just too useful for data analysis, methinks. ;) $\endgroup$ Commented Sep 23, 2011 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .