At 11:36 AM -0400 7/10/03, JP Grossman wrote:
This is mostly correct, except the computation for standard deviation is
StandardDeviation(stream) return(sqrt( (stream.squareSum - (stream.sum)^2/stream.count) / (stream.count - 1) ))
When computing standard deviation, you divide by n if you know the mean a-priori, and you divide by n-1 if you are calculating the mean from the data.
Dividing by n-1 (and not taking the square root) gives you an unbiased estimate of the variance. I'm not familiar with any formulas for unbiased estimate of the standard deviation (this would be an interesting exercise!). Keep in mind that unbiased estimators are not necessarily superior to other estimators. There is a nice demonstration of this in the March 2003 American Math Monthly: "An Illuminating Counterexample" by Michael Hardy, p. 234-238. Paul