I would like to compute STD in one-pass, without first computing the mean: Hence, I decided to use the following [formula][1]:
std dev = sqrt [(B - A^2/N)/N]
where
A is the sum of the data values;
B is the sum of the squared data values;
N is the number of data values.
And I am using float precision (cannot use double).
However, It happens that sometimes when B is very close to the value of A^2/N, I am getting a negative values for (B - A^2/N)/N, which doesn't happen when doing it the straightforward way.
Any ideas where this might be coming from?