A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-January/041997.html below:

[Python-Dev] Accumulation module

[Python-Dev] Accumulation module [Python-Dev] Accumulation moduleKevin Jacobs jacobs at penguin.theopalgroup.com
Tue Jan 13 15:26:43 EST 2004
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


More information about the Python-Dev mailing list

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