I want to create an adaptive filter. Its coefficients have this general shape:
When the input signal for the filter is a sine wave, the filter behaves the desired way if the look-back window is set to a length equal to 1/4th the period of the sine wave. I can somehow understand why this is so because a sinusoid is essentially 4 times the same piece of data, flipped and mirrored: this becomes obvious if you split it at multiples of pi/2:
When I say "the filter behaves the desired way" I mean that it turns together with the sinusoid:
.. now the question is: when the adaptive filter is placed on a sinusoid of unknown frequency, what error criterion should it use so it automatically will select a window length of 1/4th the period of the sinusoid, and behave in the same nice way as the image above? No matter where the starting point of the calculation is (so also if it does not start calculating at those "pretty" pi/2 multiples).
The goal would be to find the right length of the window. To do this, you need to go through lengths of i.e. 2->100, and always calculate the same error function, but on a longer and longer input window (going back from the current period to the left: further and further "back in time").
So we take the filter coefficients, multiply them with a piece of sinusoid, and then on this we calculate the error function: for 2 periods, for 3, for 4 etc. all the way to i.e. 100.
What is the ideal error function to use for this? Some sort of sinusoidal mean squared error type of thing.. All help appreciated.