With weight vector I mean the vector with weights that you have to multiply the observations in the window that slides over your data with so if you add those products together it returns the value of the EMA on the right side of the window.
For a linear weighted moving average the formula for finding the weight vector is: (1:n)/sum(1:n)
(in R code). This series of length n
adds up to 1. For n=10
it will be
0.01818182
0.03636364
0.05454545
0.07272727
0.09090909
0.10909091
0.12727273
0.14545455
0.16363636
0.18181818
the numbers 1 to 10 / 55, with 55 the sum of the numbers 1 to 10.
How do you calculate the weight vector for an exponential moving average (EMA) of length n?
if
n
is the length of the window, thenalpha<-2/(n+1)
andi<-1:n
soEmaWeightVector<-((alpha*(1-alpha)^(1-i)))
Is this correct?
Even though the EMA is not really confined to a window with a start and an end, shouldn't the weights add up to 1 just like with the LWMA?