I am looking for -or trying to create- a filter with a piece-wise monotonic second derivative in such a way that when placed on a non-periodic input signal, changes in sign of the second derivative happen as soon as possible and piece-wise monotonicity of the second derivative (so also of the first derivative and the filter itself) is kept intact at all time.
Let me explain: I have a non-periodic, stationary signal. On this signal, I calculate a Triangular Weighted Moving Average (SWMA): the impulse response vector looks like the positive part of a sinusoid, the weights of the moving average add up to 1. It's a FIR filter, I think a low-pass filter. What I like about this filter is that its changes in sign of its second derivative ("bending points") coincide roughly with the local extrema of my signal (like it's switching from "convex" to "concave"): if I would place a spline on it, the spline's stationary points would more or less coincide with these "second derivative sign switching points" or bending points of the filter.
I am trying to predict up/down segments using the 1st and 2nd derivative of the filter: if the SWMA was declining and the second derivative is also negative, I wait for the second derivative to turn positive and that is where my predictor turns positive for the signal, then later, when the SWMA is going up, I wait for a deceleration: for the second derivative of the SWMA to go from positive to negative: that is when my prediction turns negative for the signal. It is a causal / real-time system.
This filter (SWMA) has a lag, but because its second derivative is either going up for a while, or going down for some time (=piece-wise monotonic) I can use the bending points: look at a change in the sign of the second derivative, instead of simply looking at the slope.
The issue with my SWMA is that its second derivative is not exactly piece-wise monotonic: there's a bit of noise around turning points. Instead of filtering this second derivative with a low-pass filter, do you know any other filters that score better on this property? Or how would you construct a filter with the desired behavior?
Take a look at this image.
The purple line in the upper panel is a smoothing spline, the thin gray line is my signal, and the yellow line is a sine-weighted moving average (window length 14). The red circles on the yellow line are where the momentum starts to slow: if the filter is rising, then that's where the acceleration stops and the rising starts to slow, if the filter is decreasing, the red circle is where the acceleration in the decline stops and the decrease starts to go slower. You see that these points coincide with the turning points of the smoothing spline. Now this is a hand-picked example, showing ideal behavior of what I want to achieve. In reality, the transition between an increasing momentum and a decreasing momentum section of the filter is not so abrupt: it is noisier. If you looked at a sinusoid with period 2pi, these transitions would also be very strict (at pi/4, 3pi/4, 5pi/4 and 7pi/4). Is there a causal filter that also has this property?
Thank you for any feedback.