From: Joel VanderWerf Date: 2006-12-03T05:07:18+09:00 Subject: Re: [OT] calculations on lists of numbers Olivier wrote: ... > I'm currently coding a ruby program for processing images. One of the class I > wrote is intended to compute some stats about the luminance of a channel, but > in fact it can be used on any set of numerical datas. The stats are : > - an histogram > - the mean > - the variance > - the deviation > - the median > - the skewness > - the kurtosis > > It is very fast, since it uses no memory : the values are not stored > internally, just the sub-results (so, a list of 2 values will use the same > amount of memory than a list of a billion values), and also because the > method that adds a value is generated depending of what stats you want to > compute. 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. 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.) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407