Joel VanderWerf <vjoel / path.berkeley.edu> writes:

> What's the secret to computing stdev in bounded space? The formulas
> I know (I am not much of a statistician) require you to know the
> mean in advance.

That would be strange.

> Do you do it in two passes through the data, first getting the mean
> and then the stdev? (But this would not work if you are reading data
> from stdin and don't want to cache the data in memory.)

No.  There are several ways to do this.  Basically you want to have
sqrt(sum (x- (sum x/n))^2/(n-1))
which is
sqrt((sum x^2 - ((sum x)^2/n))/(n-1))
Now while you can sum this as you go, it is not numerically stable if
you are unlucky.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum