Optimum sampling strategy for unknown function

60 Views Asked by At

this question is derived from a technical context (which I'll describe below so you get where this is aimed), but I think it's more of a math probelm: Assume you want to measure a sensor output which can have values from say 0 to 100 (we measure every second for example). This could be a temperature or a pressure or something like this. Now, sometimes nothing much happens for a long time, but then there may be a quick rise of temp/pressure/whatever. What I want to do is to log the value but not waste a lot of memory on logging basically the same value over and over again (memory space is the expensive quantity), but on the other hand I do not want to loose information in case something "interesting" happens. Lastly, the signal may be noisy. Thats it for the technical background.

The first idea that comes to mind is sampling with an equidistant sampling time interval (every five minutes or so). But this may lead to either producing lots of useless data or miss interesting movements.

My second thought is to lay a grid over the area, e.g. only measure when the signal crosses a line on the grid, e.g. when it goes from 0x to 1x and so on. But in this case you could be ending up with signals that slightly vary from say 9 to 11 and although the signal is basically constant you produce a lot of data. Furthermore, if you choose the distances to small you log a lot of noise.

Third idea: only log when the signal has changed by a certain relative amount, e.g. 10 percent, but then a change from 1 to 2 is 100 percent, while in a region of 90 only a change of 9 will trigger the next log-event, although this might be the region of interest.

I dont find any of the above ideas are good enough and I have the feeling that there might be some elegant solution to this I just couldn't think of. I don't even have a term to search for or what this might be related to. Lastly I hope its ok to not include any graphs or equations, I hope that you can understand clearly what I am asking for, Thanks.

EDIT: I am working on a microcontroller, so no complicated post-processing is easily possible.