A Difference of WMA & EMA on a sinusoid becomes superposed?

AI Thread Summary
The discussion centers on the relationship between weighted moving averages (WMA) and exponential moving averages (EMA) when applied to a sinusoidal signal. Specifically, when a WMA with a lookback window of n/4 is subtracted from an EMA with an alpha of 1/(n/4), the resulting difference is in perfect phase with the original sinusoid. This phenomenon raises questions about the underlying reasons, such as the properties of sine waves, the characteristics of the filters, and the implications of negative filter weights in causal time series analysis. Participants express intrigue and seek a deeper understanding of why this specific configuration yields such a consistent result. The conversation emphasizes the need for further exploration and mathematical verification of these observations.
MisterH
Messages
12
Reaction score
0
This is about signal processing, moving averages & superposed / standing waves. This is an online system: causal (univariate) time series analysis.

Suppose you have a sinusoid of period n (i.e. n=40, so its frequency is 0.025). If you calculate a "weighted moving average" (WMA) on this sinusoid with a lookback-window equal to 1/4th the period of the sinusoid (i.e. 40/4 = 10), and from this WMA, you subtract an "exponential moving average" (EMA) with an alpha equal to 1 divided by 1/4th the period of the sinusoid (i.e. 1/10 = EMA alpha of 0.1), the resulting difference is perfectly "in phase" with the sinusoid. But this is only true if you do it for the n/4 setting. In fact, the result looks a lot like a superposed, standing wave: like in this image:
ex.png


This cannot be a coincidence. There must be some kind of "deeper" reason that I fail to understand: why is this only true, if you pick n/4 for the WMA, and its equivalent for the EMA, and if you compare this exact difference (WMA-EMA) with the input wave signal, they are exactly in-phase: they turn at the same moment, and reach 0 at the same moment in time. There is no phase difference. Why?

Could it be related to the fact that a sine wave is made up of 4 identical pieces? (mirrored and inverted)?
Or something about the sine & cosine and the unit circle?
Or is it related to the lag / group delay of the WMA and EMA filters?
Or to the fact that this difference (WMA-EMA) has negative filter weights (not common in causal time series analysis)?

Why o why is this so.. I just know it's not a coincidence, there is a real explanation to this. Please help me because this intrigues me :) Thanks!
 
Mathematics news on Phys.org
Did you write down the formulas and see if it works out?
 
mfb said:
Did you write down the formulas and see if it works out?

I wrote the code for the image posted above myself in r. So yes, I did write down the formulas.
 
That's not what I meant. Plug in a sine, subtract them, then simplify the expression, and see if you get a sine where you can calculate the phase.
 
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