[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
filter() not giving me correct answers for first n-1 days
From: |
Tim Rueth |
Subject: |
filter() not giving me correct answers for first n-1 days |
Date: |
Thu, 16 Sep 2010 11:41:20 -0700 |
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
- filter() not giving me correct answers for first n-1 days,
Tim Rueth <=