Reputation: 41
I was looking for a one-pass way to calculate variance over a sliding window. I found an efficient way using Power Sum Averages.However, I am looking for a solution that doesn't require me to store previous data points. Although, the above mechanism requires just 1 historic value (series[bar-period]) to calculate the current variance. In a sliding window, in effect it requires all the values for future calculations.
Is there a workaround to this problem?
Upvotes: 1
Views: 1782
Reputation: 471
You have a couple of options:
Use an incremental algorithm for mean/variance and add the element you are dropping out of the window with a weight of -1. But you still need to store them all so you know what to drop. You may be asking for the impossible.
You might try the Python momentum package, or translate from the same, if you want a really small state. I am the author.
Upvotes: 0