I'm interested in approximating a continuous curve (actually a data trace) with step functions. I know this is very similar to approximating the area under a curve with rectangles, but there is a slight twist.
My signal data is a function y(t), where t represents time.
The step functions can be irregularly spaced in time, ie they do not have to be regularly spaced as in approximating the area under a curve. In fact, because specifying each rectangle has a real world cost (I have to program my pump for each step change in my approximation signal), I would like to minimize the number of rectangles.
Is there a good approach to doing this? I apologize if this is the wrong stackexchange. I think it's a better topic for a numerical methods SE but couldn't find one. All of the approaches I can think of are somewhat brute force and involve generate n rectangles, randomly specifying their widths, and iterating towards a local minima of the difference in area specified by my input signal and my approximation signal.