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.


I think what you are searching for are simple functions. They are also related to integration, Lebesgue integration. They allow different spacing and are more advanced than the rectangles.

What are the properties of your signal? If you are going to write a program for a pump, maybe the way to go is to measure the error between your current step and the signal. If the error is bigger than some threshold you re-adjust?

  • $\begingroup$ Thanks! Lebesgue integration definitely looks interesting but it seems like it is constrained to be evenly spaced in the y-axis direction. My step functions can be of arbitrary height. My signal is quite messy. It's literally someone turning a knob to manually control a pump. I'd like to represent that control curve but with using a lot less information (rather than specifying a value every second). $\endgroup$ – user959555 Dec 10 '15 at 6:09

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.