I'd like to have a exponentially weighted moving average (EWMA) which is raised to the value of the input signal whenever this is higher than the filter output. This taking of the maximum shall take place during the iteration, not afterwards (which would be simple).
So, the algorithm should look like this:
o = 0 # or some arbitrary initial value for i in input: o = (o * 99 + i) / 100 if i > o: o = i print o
So effectively, my output shall fall slowly after a quickly falling edge in the input without rising quickly before a rising edge.
In fact, any other algorithm which just copies the input except for the places where it has a rapidly falling edge (there it should play parachute and let the output fall slower) would do fine.
The only restriction I have is that this needs to be implemented in the usual Python libraries (
pandas); iterating myself will not be fast enough.
I tried applying a rolling maximum, followed by a rolling mean with a Gaussian window of the same width (using
pandas.Series(arr).rolling()); this gives me nice smoothing of the fall after a falling edge; unfortunately it also gives me an equal smoothing before the rising edges (which I don't want).
If there was a way to apply an asymmetric Gaussian window (e. g. rising slowly and falling quickly) that would be a solution I guess. But I haven't found a way to achieve this yet.