Thu, 10 Jul 2003 11:20:52 -0400 "Bernie Cosell" <bernie@fantasyfarm.com> I thought *SURE* I knew an algorithm once, long ago, for calculating the SD "on the fly", ... Basically, I have a largish data set that it will only be convenient to read once and I'd like to be able to calculate [or at least estimate] the SD as the data comes by and avoid having to scroll it into a temp file and then do a second pass over the data from the temp file... Is there such an algorithm or am I just misremembering? I am probably misunderstandinng what you mean, but if you keep the running sum of the elements, and a running sum of the squares, then you can get the SD at any time, in one pass with the following (well known, simple) algorithm: (I tried to use a form of pseudo-code that isn't partial to any particular "real" language) NewDatum(stream, datum) stream.count = stream.count + 1; stream.sum = stream.sum + datum; stream.squareSum = stream.squareSum + datum^2; end StandardDeviation(stream) return(sqrt(stream.squareSum/stream.count - (stream.sum/stream.count)^2)); end