3
$\begingroup$

I recently read a paper where it was stated that calculus was used to calculate the slope of a moving average line at a given point. Given that there is no real formula to differentiate with a moving average calculation, what approach could the authors possibly be using?

  • 0
    BTW, generally it is a good idea to *edit your question and include the clarifying information* instead of just posting it as a comment. In addition for making it easier for later readers to figure out the important info, I note that none of the other commenters likely have seen your "clarification in a comment". By editing the question you would bump it back up on the front page and people will be able to see the information you provided.2011-08-13

1 Answers 1

8

A moving average is, by definition, the average of some number of previous data points. In the case of continuous function $f:\mathbb{R}\to\mathbb{R}$, we can define the "simple moving average" (SMA) with window size $\mathbb{R}\ni w > 0$ to be the function

$\bar{f}_w(x) = \frac{1}{w}\int_{x-w}^x f(y) dy $

In the case of a discrete function $g: \mathbb{Z}\to\mathbb{R}$ as likely in the case of financial applications, the SMA with window size $w\in\mathbb{N}$ is simply

$ \bar{g}_w(x) = \frac{1}{w}\sum_{k = 0}^{w-1} g(x - k) $

Now, for the continuous case, by the fundamental theorem of calculus, the derivative of the SMA is simply

$ \frac{d}{dx}\bar{f}_w(x) = \frac{1}{w}(f(x) - f(x-w)) $

and for the discrete case, using the difference quotient, we have that

$ D_- \bar{g}_w(x) = \frac{1}{w} (g(x) - g(x-w)) $

Notice that the formula for the derivative of the SMA is the same in the discrete and continuous case!


Now, I cannot explain the sentence "Using calculus ..." The paper you linked to is also somewhat lacking in details for me to decipher what exactly the authors had in mind. One possibility, however, is that they just meant the above observation: even though the financial data is given discretely, and not continuously in time, we have that by the above observation the following nice fact:

Let $g:\mathbb{Z}\to\mathbb{R}$ be a function defined only on integer time-steps. And let $f:\mathbb{R}\to\mathbb{R}$ be any fixed arbitrary continuous extension of $g$; that is, $f$ is a continuous function with the property that $f(n) = g(n)$ for any integer $n$. Define the SMA as above and compute their derivatives, then necessarily $\frac{d}{dt}\bar{f}_w(n) = D_-\bar{g}_w(n)$ for any integer $n$.

Which says that "it doesn't matter that calculus cannot be applied to functions defined on a discrete domain; when dealing with SMAs, the discrete and continuous pictures give the same answers when you evaluate them at the integral timesteps."