6
$\begingroup$

Is there a way to remove the noise and smooth the graph into a staircase graph.

enter image description here

$\endgroup$
4
$\begingroup$

Assuming you meant to produce something similar to the green line:

What about

$$\text{output}[n] = \max\{\text{input}[n-k], \text{input}[n-k+1], \ldots ,\text{input}[n]\}$$

i.e. you just find the maximum along a sliding window over the last $k$ input values?

$\endgroup$
5
  • 2
    $\begingroup$ It won't yield the green in the middle with the high amplitude. It will also elongate the signal when going form high value to lower one. But it is nice and simple. $\endgroup$ – Royi Jul 25 '20 at 13:48
  • $\begingroup$ @Royi, Indeed nice and simple $\endgroup$ – User Jul 25 '20 at 14:00
  • 1
    $\begingroup$ One of the unwritten rules of engineering is the simple solution is the right solution. Hence my +1. In case the noise would be whiter and you want to estimate the DC level, then you may use Total Variation based denoising. $\endgroup$ – Royi Jul 25 '20 at 14:06
  • 1
    $\begingroup$ @Royi The simplest solution is usually the right solution $\endgroup$ – Ben Jul 25 '20 at 15:33
  • $\begingroup$ I'd prefer to do the average of the max samples over the previous n samples, given the otherwise high sensitivity to noise based on any one sample--- but if there is no chance of such "noise" deviation, this answer is perfect, given k should be limited to just the maximum drop time (a sample and hold over 5 samples for example.) The plot seems inconsistent to me, given the region where the selection is along the bottom--- author error? $\endgroup$ – Dan Boschen Jul 26 '20 at 3:15

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.