Make a signal that fits another the best possible with a limitation in the 2nd derivative Consider this step function:




The signal that "fits" this should look like the following (in green):


The corners are now smooth because the maximum second derivative allowed is not infinite anymore.



The idea is to find the most close to the original signal given the maximum second derivative allowed, minimizing the difference between the two signals (in orange):




If your system can predict things before it happens it could do something like this:


Minimizing the total difference even more. But also could be achieved if it works in non real time or has some kind of look ahead. But that will be not always possible or desirable.
This is not in the very core of my question, however is also a interesting option.



So, my question is: How can this be done? Is it possible (eg: exist more than one curve that minimizes error to the same value)?

Also to me looks like a filter, is there any filter which definition is something like this (hopefully a digital one)?
Hmmmmmmmmm, interesting question.

Since you want to use the second derivative as your criteria, it would seem that you would want to have the maximum second derivative absolutie value for as short of a duration as possible.  This would suggest piecing together parabolas, matching the first derivatives at the joints.

How to do this algorithmically will take a little more thought.  Somehow you have to identify regions of "violations" and then figure out how big of an interval you have to use to patch it piecewise with parabolas.

Just some thoughts.  If I think of a sure fire way, I'll add it on.

Ced



Followup:

It turns out to be really simple to make a FIR that reacts to a step function with a upward parabola for the first half and a downward parabola for the second half.  It just becomes a matter of selecting the width and the rise rate to set the value of the second derivative.  I haven't done the math yet for the actual value, but here is a program which gives proof of concept.

 h[k] = [ 1  2  3  4  3  2  1 ]  / 16 

It appears the second derivative proxy $ y[n-1] - 2 * y[n] + y[n+1] $ has an absolute value of the normalizing factor of the integer step vector, e.g. $1/16$.


import numpy as np

#======================================================================
def main():

        P = 2

#---- Build the Weights

        K = 2 * P - 1

        h = np.zeros( K )

        for k in range( P ):
            h[k] = k + 1

        for k in range( P - 1 ):
            h[P+k] = P - k - 1

        theRecip = 1.0 / sum( h )

        print h, sum( h )

        h *= theRecip

        print h

#---- Set up the Step Function

        x = np.zeros( 20 )

        x[10:20] = 1.0

        print x

#---- Apply Filter

        y = np.zeros( 20 )

        for n in range( 8, 20 ):
            Sum = 0.0            
            for k in range( K ):
                Sum += x[n-k] * h[k]
            y[n] = Sum

#---- Show Result

        for n in range( 6, 18 ):
            second = y[n-1] - 2.0 * y[n] + y[n+1]
            print n, y[n], second


#======================================================================
main()




Yet a better answer:

[Moved to a separate answer]