Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
what is "the moving average line"? – leonbloy Jul 15 '11 at 17:53
Do you recall the name of the paper you read? – Jan Gorzny Jul 15 '11 at 17:57
@leonbloy: Presumably the graph of the moving average, thought of as a smoothed curve through the actual discrete set of points. – Brian M. Scott Jul 15 '11 at 18:21
Is it possible that they simply meant that the slope was calculated as a difference quotient? In financial contexts I’ve seen both $\frac{x_n - x_{n-1}}{t_n - t_{n-1}}$ and $\frac{x_{n+1} - x_{n-1}}{t_{n+1} - t_{n-1}}$ referred to as the slope at $(t_n,x_n)$, where $x_n$ is the $n$-th moving average. Since the data are usually updated at constant intervals, the denominators usually normalize to $1$ and $2$, respectively. – Brian M. Scott Jul 15 '11 at 18:28
The paper in question is available at The relevant section is section 3 where it is stated "Using calculus, the nine and two-month SMA trend lines are converted into a mathematical model," followed by descriptions of use in sections 3.1 and 3.2 – babelproofreader Jul 17 '11 at 17:27
up vote 4 down vote accepted

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."

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.