1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Jul 1, 2017 #1
    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!
     
  2. jcsd
  3. Jul 1, 2017 #2

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    Did you write down the formulas and see if it works out?
     
  4. Jul 2, 2017 #3
    I wrote the code for the image posted above myself in r. So yes, I did write down the formulas.
     
  5. Jul 2, 2017 #4

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Difference of WMA & EMA on a sinusoid becomes superposed?
  1. Sinusoidal Function (Replies: 2)

Loading...