Difference of WMA & EMA on a sinusoid becomes superposed?

Click For Summary
SUMMARY

The discussion focuses on the relationship between Weighted Moving Average (WMA) and Exponential Moving Average (EMA) when applied to a sinusoidal signal with a period of 40. Specifically, when a WMA with a lookback window of 10 is subtracted from an EMA with an alpha of 0.1, the resulting difference is in perfect phase with the original sinusoid. This phenomenon occurs exclusively at the n/4 setting, suggesting a deeper mathematical connection between the sinusoidal wave and the properties of these moving averages in causal time series analysis.

PREREQUISITES
  • Understanding of signal processing concepts, particularly moving averages.
  • Familiarity with sinusoidal functions and their properties.
  • Knowledge of causal time series analysis techniques.
  • Proficiency in R programming for implementing and testing formulas.
NEXT STEPS
  • Explore the mathematical derivation of WMA and EMA to understand their phase relationships.
  • Investigate the impact of filter weights in WMA and EMA on signal processing.
  • Learn about the concept of group delay in moving average filters.
  • Examine the properties of sine and cosine functions in relation to periodic signals.
USEFUL FOR

Signal processing engineers, data analysts, and researchers interested in time series analysis and the mathematical properties of moving averages.

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!
 
Physics 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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
6
Views
4K
  • · Replies 0 ·
Replies
0
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
7K