# How to find line that has least distance to all points?

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?

-
So all your points are in 2D? – Jacob Sep 23 '11 at 14:55
Yes. They are in 2D. – kravemir Sep 23 '11 at 14:56