Weights of simple moving average are not adding up to one
$begingroup$
This is the definition of linear filter from a book I am reading:
A second procedure for dealing with a trend is to use a linear filter, which converts one time series, ${x_t}$, into another, ${y_t}$, by the linear operation
$$y_t = sum_{r = -q}^{+s} a_r x_{t+r}$$
where ${a_r}$ is a set of weights. In order to smooth out local fluctuations and estimate the local mean, we should clearly choose the weights so that $sum a_r = 1$, and then the operation is often referred to as a moving average. Moving averages are discussed in detail by Kendall et al. (1983, Chapter 46), and we will only provide a brief introduction. Moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. The simplest example of a symmetric smoothing filter is the simple moving average, for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$, and the smoothed value of $x_t$ is given by
$$textrm{Sm}(x_t) = frac{1}{2q + 1}sum_{r=-q}^{+q} x_{t+r}$$
It is said there that ${a_r}$ is a set of weights and in order to call the operation a moving average we should clearly choose the weights so sum of $a_r$ is equal to 1.
Then it is described that the moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. So the simple moving average for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$ is $textrm{Sm}(x_t)$
But when I tried to confirm that the sum of $a_r$ for simple moving average equal 1 I got this:
Is there something I misunderstood?
average
$endgroup$
add a comment |
$begingroup$
This is the definition of linear filter from a book I am reading:
A second procedure for dealing with a trend is to use a linear filter, which converts one time series, ${x_t}$, into another, ${y_t}$, by the linear operation
$$y_t = sum_{r = -q}^{+s} a_r x_{t+r}$$
where ${a_r}$ is a set of weights. In order to smooth out local fluctuations and estimate the local mean, we should clearly choose the weights so that $sum a_r = 1$, and then the operation is often referred to as a moving average. Moving averages are discussed in detail by Kendall et al. (1983, Chapter 46), and we will only provide a brief introduction. Moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. The simplest example of a symmetric smoothing filter is the simple moving average, for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$, and the smoothed value of $x_t$ is given by
$$textrm{Sm}(x_t) = frac{1}{2q + 1}sum_{r=-q}^{+q} x_{t+r}$$
It is said there that ${a_r}$ is a set of weights and in order to call the operation a moving average we should clearly choose the weights so sum of $a_r$ is equal to 1.
Then it is described that the moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. So the simple moving average for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$ is $textrm{Sm}(x_t)$
But when I tried to confirm that the sum of $a_r$ for simple moving average equal 1 I got this:
Is there something I misunderstood?
average
$endgroup$
add a comment |
$begingroup$
This is the definition of linear filter from a book I am reading:
A second procedure for dealing with a trend is to use a linear filter, which converts one time series, ${x_t}$, into another, ${y_t}$, by the linear operation
$$y_t = sum_{r = -q}^{+s} a_r x_{t+r}$$
where ${a_r}$ is a set of weights. In order to smooth out local fluctuations and estimate the local mean, we should clearly choose the weights so that $sum a_r = 1$, and then the operation is often referred to as a moving average. Moving averages are discussed in detail by Kendall et al. (1983, Chapter 46), and we will only provide a brief introduction. Moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. The simplest example of a symmetric smoothing filter is the simple moving average, for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$, and the smoothed value of $x_t$ is given by
$$textrm{Sm}(x_t) = frac{1}{2q + 1}sum_{r=-q}^{+q} x_{t+r}$$
It is said there that ${a_r}$ is a set of weights and in order to call the operation a moving average we should clearly choose the weights so sum of $a_r$ is equal to 1.
Then it is described that the moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. So the simple moving average for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$ is $textrm{Sm}(x_t)$
But when I tried to confirm that the sum of $a_r$ for simple moving average equal 1 I got this:
Is there something I misunderstood?
average
$endgroup$
This is the definition of linear filter from a book I am reading:
A second procedure for dealing with a trend is to use a linear filter, which converts one time series, ${x_t}$, into another, ${y_t}$, by the linear operation
$$y_t = sum_{r = -q}^{+s} a_r x_{t+r}$$
where ${a_r}$ is a set of weights. In order to smooth out local fluctuations and estimate the local mean, we should clearly choose the weights so that $sum a_r = 1$, and then the operation is often referred to as a moving average. Moving averages are discussed in detail by Kendall et al. (1983, Chapter 46), and we will only provide a brief introduction. Moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. The simplest example of a symmetric smoothing filter is the simple moving average, for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$, and the smoothed value of $x_t$ is given by
$$textrm{Sm}(x_t) = frac{1}{2q + 1}sum_{r=-q}^{+q} x_{t+r}$$
It is said there that ${a_r}$ is a set of weights and in order to call the operation a moving average we should clearly choose the weights so sum of $a_r$ is equal to 1.
Then it is described that the moving averages are often symmetric with $s = q$ and $a_j = a_{-j}$. So the simple moving average for which $a_r = 1/(2q + 1)$ for $r = -q, ldots, +q$ is $textrm{Sm}(x_t)$
But when I tried to confirm that the sum of $a_r$ for simple moving average equal 1 I got this:
Is there something I misunderstood?
average
average
edited Dec 16 '18 at 3:45
Mark H
1,00368
1,00368
asked Dec 15 '18 at 16:41
Kocur4dKocur4d
1184
1184
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
In your code, you have computed [1/(2 * ele + 1) for ele in r]
, which (in your example) is
$$ left[ frac{-1}{9}, frac{-1}{7}, frac{-1}{5}, frac{-1}{3}, -1, 1, frac{1}{3}, frac{1}{5}, frac{1}{7}, frac{1}{9}, frac{1}{11} right] text{.} $$ When you sum those up, you get $frac{1}{11} = 0.overline{09}$, as you observed.
However, the book specifies that you use $frac{1}{2q+1}$, so [1/(2 * q + 1) for ele in r]
, which will give
$$ left[ frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11} right] text{.} $$
Summing those gives $1$, as expected. Also, the simplest moving average should weight all of its inputs equally, which is what happens here.
$endgroup$
add a comment |
$begingroup$
Note that the book defines $a_r = frac{1}{2q + 1}$ where $a_r$ does NOT depend on $r$, but only on $q$. Since $q$ is fixed, all of the $a_r$ should be the same. In your code, you calculate $a_r = frac{1}{2r + 1}$ instead.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3041694%2fweights-of-simple-moving-average-are-not-adding-up-to-one%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
In your code, you have computed [1/(2 * ele + 1) for ele in r]
, which (in your example) is
$$ left[ frac{-1}{9}, frac{-1}{7}, frac{-1}{5}, frac{-1}{3}, -1, 1, frac{1}{3}, frac{1}{5}, frac{1}{7}, frac{1}{9}, frac{1}{11} right] text{.} $$ When you sum those up, you get $frac{1}{11} = 0.overline{09}$, as you observed.
However, the book specifies that you use $frac{1}{2q+1}$, so [1/(2 * q + 1) for ele in r]
, which will give
$$ left[ frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11} right] text{.} $$
Summing those gives $1$, as expected. Also, the simplest moving average should weight all of its inputs equally, which is what happens here.
$endgroup$
add a comment |
$begingroup$
In your code, you have computed [1/(2 * ele + 1) for ele in r]
, which (in your example) is
$$ left[ frac{-1}{9}, frac{-1}{7}, frac{-1}{5}, frac{-1}{3}, -1, 1, frac{1}{3}, frac{1}{5}, frac{1}{7}, frac{1}{9}, frac{1}{11} right] text{.} $$ When you sum those up, you get $frac{1}{11} = 0.overline{09}$, as you observed.
However, the book specifies that you use $frac{1}{2q+1}$, so [1/(2 * q + 1) for ele in r]
, which will give
$$ left[ frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11} right] text{.} $$
Summing those gives $1$, as expected. Also, the simplest moving average should weight all of its inputs equally, which is what happens here.
$endgroup$
add a comment |
$begingroup$
In your code, you have computed [1/(2 * ele + 1) for ele in r]
, which (in your example) is
$$ left[ frac{-1}{9}, frac{-1}{7}, frac{-1}{5}, frac{-1}{3}, -1, 1, frac{1}{3}, frac{1}{5}, frac{1}{7}, frac{1}{9}, frac{1}{11} right] text{.} $$ When you sum those up, you get $frac{1}{11} = 0.overline{09}$, as you observed.
However, the book specifies that you use $frac{1}{2q+1}$, so [1/(2 * q + 1) for ele in r]
, which will give
$$ left[ frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11} right] text{.} $$
Summing those gives $1$, as expected. Also, the simplest moving average should weight all of its inputs equally, which is what happens here.
$endgroup$
In your code, you have computed [1/(2 * ele + 1) for ele in r]
, which (in your example) is
$$ left[ frac{-1}{9}, frac{-1}{7}, frac{-1}{5}, frac{-1}{3}, -1, 1, frac{1}{3}, frac{1}{5}, frac{1}{7}, frac{1}{9}, frac{1}{11} right] text{.} $$ When you sum those up, you get $frac{1}{11} = 0.overline{09}$, as you observed.
However, the book specifies that you use $frac{1}{2q+1}$, so [1/(2 * q + 1) for ele in r]
, which will give
$$ left[ frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11}, frac{1}{11} right] text{.} $$
Summing those gives $1$, as expected. Also, the simplest moving average should weight all of its inputs equally, which is what happens here.
answered Dec 15 '18 at 17:02
Eric TowersEric Towers
32.6k22370
32.6k22370
add a comment |
add a comment |
$begingroup$
Note that the book defines $a_r = frac{1}{2q + 1}$ where $a_r$ does NOT depend on $r$, but only on $q$. Since $q$ is fixed, all of the $a_r$ should be the same. In your code, you calculate $a_r = frac{1}{2r + 1}$ instead.
$endgroup$
add a comment |
$begingroup$
Note that the book defines $a_r = frac{1}{2q + 1}$ where $a_r$ does NOT depend on $r$, but only on $q$. Since $q$ is fixed, all of the $a_r$ should be the same. In your code, you calculate $a_r = frac{1}{2r + 1}$ instead.
$endgroup$
add a comment |
$begingroup$
Note that the book defines $a_r = frac{1}{2q + 1}$ where $a_r$ does NOT depend on $r$, but only on $q$. Since $q$ is fixed, all of the $a_r$ should be the same. In your code, you calculate $a_r = frac{1}{2r + 1}$ instead.
$endgroup$
Note that the book defines $a_r = frac{1}{2q + 1}$ where $a_r$ does NOT depend on $r$, but only on $q$. Since $q$ is fixed, all of the $a_r$ should be the same. In your code, you calculate $a_r = frac{1}{2r + 1}$ instead.
answered Dec 15 '18 at 16:48
AlexAlex
43128
43128
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3041694%2fweights-of-simple-moving-average-are-not-adding-up-to-one%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown