Skip to content

Instantly share code, notes, and snippets.

@isaiah-perumalla
Last active November 26, 2019 16:20
Show Gist options
  • Save isaiah-perumalla/98b0b1656712f1b3a170a548516fbcf5 to your computer and use it in GitHub Desktop.
Save isaiah-perumalla/98b0b1656712f1b3a170a548516fbcf5 to your computer and use it in GitHub Desktop.
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