Last active
November 26, 2019 16:20
-
-
Save isaiah-perumalla/98b0b1656712f1b3a170a548516fbcf5 to your computer and use it in GitHub Desktop.
some python functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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