1
$\begingroup$

Given points on graph, the popular method of fitting a line is by using the least-squares method. I need a different method - I need the worst error, i.e. the largest distance from a point to the line, to be as small as possible.

I need to implement it in Matlab, so if it provides relevant functions, that would be awesome.

Example:

graph

The least-squares method would bring the line near the bottom dots, but the method that I need should bring it in the middle, because that would minimize the worst error.

1 Answers 1

3

What you're doing is called "minimax approximation", because you are trying to minimize the maximum error.

Alternatively, it's called "uniform approximation" because the error is measured using the uniform ($L_\infty$) norm, rather than the $L_2$ norm used in least-squares fitting.

You can find some useful material by googling these two terms.

For minimax approximation of a function by a polynomial, the standard technique is the Remez algorithm, which is fairly complicated. Your case is much simpler than this. You basically have only two variables (the slope and intercept of the line), so any decent optimization function should be able to find the best solution.

  • 0
    Thank you! I found an implementation here: http://stackoverflow.com/questions/20364675/minimizing-l-infinity-norm-in-matlab2017-01-20