Difference of WMA & EMA on a sinusoid becomes superposed?

Click For Summary

Discussion Overview

The discussion revolves around the relationship between weighted moving averages (WMA) and exponential moving averages (EMA) applied to a sinusoidal signal in the context of signal processing. Participants explore the conditions under which the difference between these two averages becomes superposed with the original sinusoid, particularly focusing on the implications of using specific parameters related to the period of the sinusoid.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant notes that calculating a WMA with a lookback window of n/4 and an EMA with an alpha of 1/10 results in a difference that is in phase with the original sinusoid.
  • There is speculation about whether this phenomenon is related to the structure of the sine wave, its representation in the unit circle, or the properties of the filters used.
  • Another participant suggests verifying the results by plugging in a sine wave and simplifying the expression to analyze the phase relationship.
  • One participant confirms they have already derived the formulas and implemented them in code, indicating a level of technical engagement with the problem.

Areas of Agreement / Disagreement

Participants express differing views on the underlying reasons for the observed phenomenon, with some proposing various theoretical explanations while others focus on the need for empirical verification through calculations.

Contextual Notes

The discussion involves assumptions about the properties of moving averages and their interaction with sinusoidal signals, which may not be universally applicable without further mathematical justification.

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
6K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
6
Views
4K
  • · Replies 0 ·
Replies
0
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
7K