0

The problem is following. I have 1D array of data, that i need to approximate by a given amount of horizontal lines (for example, by 3 lines) in the optimal way (so, the summary error becomes minimal). The method of approximation should be as fast as possible (so, i cannot take every horizontal line, approximate data set, extract it value from data set and approximate the rest by the reamaining set of lines). Now, i have no idea how to do it except slightly feeling that the solution of this problem is linked to the solution of the maximum subarray problem. Please, could you give me some advices how to solve it?

1 Answers1

0

The least-squares approximation of a 1D set of data is by definition its arithmetic mean, so there's one of your lines. I'm not sure what criterion you'd want to use for the other two.

ebohlman
  • 14,795
  • 5
  • 33
  • 35
  • ebohlman, least square approximation could be performed not only by line (i.e. function a*x + b*y + c = 0) but by every parametrized function (i.e. 'f(x) = a if x in (c1,c2), b if x in (c3,c4), c if x in (c5,c6), d otherwise' for this function parameters are {a,b,c,d, c1,c2,c3,c4,c5,c6}. That is my case. – distantTransformer Jun 28 '12 at 09:50