= x1 and S1 = 0. For subsequent x‘s, use the recurrence formulas Mk = Mk-1+ (xk – Mk-1)/k Sk = Sk-1 + (xk – Mk-1)*(xk – Mk). For 2 ≤ k ≤ n, the kth estimate of the variance is s2 = Sk/(k – 1). Accurately computing running variance https://www.johndcook.com/blog/standard_deviation/