Skip to content

Instantly share code, notes, and snippets.

@jsatt
Created June 24, 2013 21:33
Show Gist options
  • Save jsatt/5853801 to your computer and use it in GitHub Desktop.
Save jsatt/5853801 to your computer and use it in GitHub Desktop.
running average in python
def running_sum_generator(iterable):
sum = 0
for i in iterable:
if not i:
continue
sum += i
yield sum
def running_avg(value_list):
return [float(sum) / (i + 1) for (i, sum) in
enumerate(running_sum_generator(value_list))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment