I'm trying to develop a real time algorithm for finding level areas of an electrical signal.
To do so I need to find the variance for a particular rolling time interval.
From John Cook's blog and the Art of Computer Programming the algorithm for quickly determining variance is:
Mk = Mk-1 + (xk - Mk-1)/k
Sk = Sk-1 + (xk - Mk-1) * (xk - Mk)
Where the kth estimate of the variance is:
$ s^2 = S_k / (k-1) $
This works great, but I need to keep a 'rolling' variance of 100 samples. With each step I would add one new sample and take the 100th sample off the list.
If I know the value of xk-100 is there a quick algorithm for 'erasing' it from the variance result?