# How to filter very low amplitude staircase signal from a background noise

I have a staircase signal of a specific pattern that is drowned in a background noise. The ratio of signal to noise amplitude is nearly $$10^{-4}$$. I have attached the image of both with this post. I am an absolute noob in this field so please suggest me a direction on which path I should start to hunt for the solution.

I have tried to do fft on both of the signal and looked for any distinct signature to filter the background noise. Also I have tried with matched filtering and basic convolution techniques. But none of these seem to work. Your advice will be much appreciated. Thanks.

• With that much noise, I'd be surprised if the signal can be recovered. If you can't amplify the signal, then try to make the steps longer (much longer) to increase their energy and improve your chances of detection. – MBaz Oct 11 '19 at 1:45
• That is not so much "noise" as it is "interference." You might do better to try and characterize that interference and see if it is some how easier to recognize than your signal. You might also go back to the source of the data and see if the interference can be physically reduced before the signal is sampled. – JRE Oct 11 '19 at 10:54
• I agree that it would be a smart idea to treat as interference. Is there a way to estimate it and subtract it off? Just looking at the plot it seems unlikely but I donâ€™t know the details. Just out of curiosity, what is the application? – Engineer Nov 10 '19 at 20:57

## 2 Answers

As suggested by Matt L., total variation denoising is probably the tool of choice.

If the staircase morphology can be trusted, I would suggest looking at the notion of piecewise constant approximation. It is often meant to approximate generic functions along the idea if Riemann sums. However, this is exactly your model here, so you can introduce jump location estimates (with derivatives) combined with judicious error metrics (like Hausdorff distances in Approximation of curves with piecewise constant or piecewise linear functions). Your can find a Matlab code in Nonlinear least-squares spline fitting with variable knots, P. Kovacs et al. 2019

Another signal processing methodology that could work is called "Finite Rate of Innovation", provided you only have a limited number of jumps per time interval.

Finally, good old median filters (and median derivative filters) are nonlinear filters that can do a great heuristic jobs.

Linear filtering won't work here. If anything works at all then it might be something like total variation denoising, which is a non-linear technique for removing noise while preserving edges. This article is a very good read, and it also shows a Matlab implementation of the algorithm.