A Fitness function for window length of filter

AI Thread Summary
The discussion focuses on developing a fitness function to determine the optimal window length for a linear weighted moving average (LWMA) filter that aligns with a sinusoidal signal. It establishes that the difference between the LWMA and an exponential moving average (EMA) is in phase with the sinusoid when the window length n equals P/4. The proposal suggests analyzing segments of the wave multiplied by the filter weights to identify the window length that maximizes the correlation with the sinusoid. The fitness function could potentially involve metrics like curvature or properties of sinusoids. Input is sought on how to effectively create this fitness function for optimal window length determination.
MisterH
Messages
12
Reaction score
0
TL;DR Summary
Find a fitness function such that: filter(LWMA-EMA) is in-phase with the sinusoid it's placed on, not by correlation, but calculated on filter weights * segment of sinusoid (that has a length equal to the filter weights), so on only 1 step of the convolution.
Fitness function for window length of filter

On a sinusoidal signal with amplitude 1, and period P, an exponential moving average (EMA) (with alpha = 1/n), and a linear weighted moving average (LWMA) (with window length n) are calculated; when you subtract the EMA from the LWMA, it can be seen that the difference of these 2 filters will be in phase with the sinusoid when the window length n of the LWMA = P/4 (and for the EMA alpha = 1/n). So if P=40, the signal: LWMA(wave,10)-EMA(wave,0.1) is in phase with the wave, but at lower amplitude. The weight function of this "difference filter" looks like this:
weights of LWMA-EMA.png

Similar, but not equal to the weights of a "zero-lag exponential moving average". It can be seen that the correlation (degree of linear association) between the wave and the filter will be maximal at n = P/4:
wave and 3 filters.png


Now, my question is: instead of looking at an entire wave, can you just look at the data in the window, multiplied with the filter weights to find which window length n will result in a signal that is in phase with the sinusoid? e.g.:
weights multiplied with wave segment.png


So at e.g. point x, wave[(x-n+1):x] is multiplied with the weight function of the difference filter, on this data, some sort of calculation is made, that returns a value e.g. between 0 and 1, with a maximum for n = P/4? So the fitness of window length n1: wave[(x-n1+1):x]*weightfunction(n1) can be compared with the fitness of window length n2: wave[(x-n2+1):x]*weightfunction(n2), and the one where n equals a -previously unknown- P/4 will return a maximum for this fitness/error function.

How would you create such a fitness function? Could it be related to curvature, or some sort of exponential fit, or some property of sinusoids?

All input is welcome and appreciated.
 
Mathematics news on Phys.org
weights multiplied with wave segment2.png
 
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Back
Top