1
$\begingroup$

I am currently trying to derive an exponentially smoothed moving average, and I would like to reach both the first and second derivatives. I have only derived basic series and am having trouble with this. I encountered this series here.

The Moving Average in question is:

$$ A_{d} = \frac{\sum_{i=1}^{d}S^{i-1}M_{(d-i)+1)}}{\sum_{i=1}^{d}S^{i-1}} $$

The notation is not the clearest, but I know it works. This is my first time posting a question. Any feedback is appreciated!

$$ $$ Edit: I am looking to take the derivative with respect to $ M_d $

  • 0
    What would you like to take the derivative with respect to? Both $A_d$ and $M_d$ are discrete sequences.2017-02-20
  • 0
    @CodeLabMaster I am looking to take the derivative with respect to Md.2017-02-21
  • 0
    As far as I'm understanding you, that doesn't make sense to do. Derivatives are something you take of continuous functions. If you treat $d$ as fixed and $M_d$ like it's a continuous variable, then you can take the partial derivative of $A_d$ with respect to $M_d$ as $$\frac{\partial A_d}{\partial M_d} = \frac{1}{\sum_{i=1}^d S^{i-1}} = \frac{1-S}{1-S^d}$$ but that isn't a thing people normally look at. Is this what you are interested in, or do you mean something else?2017-02-21
  • 0
    @CodeLabMaster Yes! That is exactly what I mean! I was just wondering how to get the first and second derivatives of that. I have not had any experience deriving series like this. I imagine this would be useful for calculating the tangent approximation of data. So if I was launching a rocket and measuring its height, I could create an average of its height, velocity, and acceleration based on the past height data at any point.2017-02-22
  • 0
    Okay, that makes sense. You want to see how the average changes with each new data point. I'll write up a clearer answer, then.2017-02-22

1 Answers 1

0

Assuming that $d$ is fixed, we can take the partial derivative of $A_d$ with respect to $M_d$ by separating out the term involving $M_d$ from the others:

$$A_d = \left( \frac{1}{\sum_{i=1}^d S^{i-1}} \right) M_d + \frac{\sum_{i=2} S^{i-1} M_{d-i+1}}{\sum_{i=1}^d S^{i-1}}$$

Now we have a function of the form $f(x) = ax + b$ whose derivative is just $f'(x) = a$, so

$$ \frac{\partial A_d}{\partial M_d} = \frac{1}{\sum_{i=1}^d S^{i-1}} = \frac{1-S}{1-S^d}$$

where the last equality uses the definition of a geometric series. Since $M_d$ no longer shows up in this expression, the second partial derivative of $A_d$ with respect to $M_d$ is just 0:

$$\frac{\partial^2 A_d}{\partial M_d^2} = 0$$

  • 0
    Thank You. This is interesting. Would not there be a problem with the second step as the second term(b) still contains M~d~, and should not that be also derived?2017-02-22
  • 0
    When $i=2$, the term in the numerator is $S^{1}M_{d-1}$ and for $i=d$ the term is $S^{d-1}M_1$. There are no more terms involving $M_d$, so we can ignore them. Taking a partial derivative with respect to a variable $x$ treats all other potential variables as constants.2017-02-22
  • 0
    Well then, does that second formula then give, in the case of the rocket example, the velocity approximation for the rocket? And should not the second derivative equal the acceleration approximation? This does not seem to be correct as the acceleration relies on the position as well.2017-02-23
  • 0
    No, this only gives how much the smoothed average $A_d$ changes with respect to the latest measurement $M_d$. If you wanted the velocity, assuming the smoothed average gave positions, you'd want $$\frac{\Delta A_t}{\Delta t} = \Delta A_t$$ to get an approximation of velocity since you don't have instantaneous position needed for instantaneous velocity.2017-02-23
  • 0
    Ohh, yes. That makes much more sense, and the units match up then. (I am coming from a physics perspective not a math one.) So is the derivative of At with respect to t calculable from the series? Can that be done, and if so what theorem should I use to start that? Thank you for your continued help with this problem.2017-02-24
  • 0
    The reason why I was confused at what you were looking for at first is that the traditional derivative doesn't exist for a series of values. If you had values for every $t$ ($.25$, $.05$, etc.), then you could find the derivative by taking the following limit: $$\frac{d A_t}{dt} = \lim_{\Delta t \to 0} \frac{\Delta A_t}{\Delta t}$$ but since you don't have that, the next best thing is the series of forward differences $$\Delta A_t = A_{t+1} - A_{t}$$. Since exponentially smoothed averages makes outliers stand out less, you should expect this to underestimate the velocity a bit.2017-02-24
  • 0
    Ok, Thank you. I had thought it would be possible to derive it to achieve a derivative approximation. This way of finding the velocity works, but does not use data from previous points which could decrease smoothing and cause (more) inaccuracy. Perhaps I could do a quadratic regression from the last three data points.2017-02-24