Octave
experts:
I have been using
filter() to compute a weighted moving average, ma1, of a vector, cls_v,
with a weighting factor, alpha. I just found out that the first num_days-1
of the moving average are not correct. I'm assuming I don't have a
filter coefficient quite correct or something, but I'm stuck. I tried
to understand the formula in help, but got lost. Any
takers?
Here's my current
code:
coef_v = (num_days : -1 :
1).^alpha;
coef_v =
coef_v/sum(coef_v);
# sum vector coefficients to equal 1
si =
repmat(cls_v(1), 1, num_days - 1);
ma1 =
filter(coef_v, 1, cls_v, si);
Thanks,
--Tim