I have a set of points in two-dimensional space. I'd like to find the line of best fit that minimizes the distance between the line and the points such that the line is below all points. How can I find the slope and intercept of a line that minimizes this distance?

  • $\begingroup$ Yes, I know OLS, but I don't want a line of best fit though the points. I want to find a line below all points. $\endgroup$ – user1728853 Jan 21 '13 at 18:19
  • $\begingroup$ Thanks for the help. Unfortunately, I don't know how to do this. Can you provide a simple explanation? $\endgroup$ – user1728853 Jan 21 '13 at 18:25
  • $\begingroup$ you can find the line with least squares and then translate this line so that he pass over the lowest point. At this point you can say that the line is below all points (except for one) $\endgroup$ – the_candyman Jan 21 '13 at 18:44
  • 1
    $\begingroup$ @the_candyman: Are you sure the translated line will be optimal among all possible lines that lie below all points? $\endgroup$ – Rahul Jan 21 '13 at 22:28

Just solve the following optimization problem for $(a,b)$: \begin{align*} \text{Minimize}&\quad \sum_{i=1}^n (y_i - (a \, x_i + b))^k \\ \text{such that}& \quad a \, x_i + b \le y_i \end{align*} Here, you can choose $k = 2$ (least squares) or $k=1$.

This is a smooth, convex problem (for $k=1$ even a linear problem). Try to write down the optimality conditions and solve them.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.