On Tue, 13 Jan 2004, Raymond Hettinger wrote: > * Is there a way to compute the standard deviation without multiple > passes over the data (one to compute the mean and a second to sum the > squares of the differences from the mean? Yes -- def one_pass_stddev(l): n = 0 x = 0. xx = 0. for y in l: n += 1 x += y xx += y*y x /= n xx /= n var = max(0,xx - x*x) dev = var**0.5 return dev Skewness and kurtosis can also be computed in one pass, though numerical stability problems can occur (even with std.dev) with these kinds of methods. -Kevin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4