I need to compute a weighted moving average withous loops and withoud storing infromation. The weight could be linear, so that the old sample is weighted less than the new one.
For example, using a 20 samples window, my weights vector would be:
[1 2 3 4 5 ... 20]
I'm using the following formula to compute the moving mean:
newMean = currMean + (newSample - currMean)/WindowSize
now I need to "inject" weight.
What I can know: 1. which sample I'm considering (14th....26th....), I can count. 2. of course, I can know currMean
What I can know but I don't want to do: 1. storing all the samples (in my case they are 1200 x 1980 x 3 matrix, I simply can't store them).
I'm currently using Matlab, but I really do not need the code, just the concept, if it exists.
Thank you.
(1:20) ./ sum(1:20)- Suever