I have weighted observations (via importance sampling) with decay and would like to calculate (iteratively) the running variance. Both this question and this blog post focus on unweighted, non-decaying variances, and I'm having a hard time incorporating weights and decays.
For reference, here is how I am calculating weights and means recursively/iteratively for each weighted observation $(v_i, w_i)$ given a decay parameter $\lambda\in [0,1]$, where 0 results in the weighted average and 1 results in a full overwrite with the new observation (useful for certain algorithms like value iteration). Note below that $t$ is calculated inclusive of observation $i=t$.
$$W_0=0, M_0=0$$ $$W_t=(1-\lambda)*W_{t-1}+w_{i}$$ $$M_t=((1-\lambda)*W_{t-1}*M_{t-1}+v_i*w_i)/W_t$$
How do I iteratively/recursively calculate the running sum-of-squared residuals?
Edited to add current attempt
$$\sigma^2_t=((1-\lambda)*W_{t-1}*\sigma^2_{t-1}+w_i*(v_i-M_{t-1})*(v_i-M_t))/W_t$$