Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
some python functions
def calc_avg(items):
if not items:
return 0
total = sum(items)
return float(total)/len(items)
def std_deviation(items):
if not items: return 0
mean = calc_avg(items)
variance = calc_avg([(x - mean)*(x - mean) for x in items])
return math.sqrt(variance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment