I have previously reviewed code that computes standard deviation using the mathematical formula E(x²) - E(x)², and warned against the use of this formula because floating-point precision is severely compromised by subtracting almost-equal numbers. I've started with the methods described in Incremental calculation of weighted mean and varianceIncremental calculation of weighted mean and variance by Tony Finch. However, I'm not an expert on numerical methods, so I'd like to know of any weaknesses in my version.