Last active
November 26, 2016 03:52
-
-
Save Porter97/1c542bdb3b47fce5202c9b29b85e98de to your computer and use it in GitHub Desktop.
This file contains 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
#sum | |
def x_sum(x_input): | |
x = 0 | |
for each in x_input: | |
x += each | |
return x | |
#average | |
def x_average(x_input): | |
x = x_sum(x_input)/float(len(x_input)) | |
return x | |
#variance | |
def x_variance(x_input): | |
num = len(x_input) | |
average = x_average(x_input) | |
variance = 0 | |
for x in x_input: | |
variance += float(average - x) ** 2 | |
return variance/num | |
#standard deviation | |
def x_std_deviation(variance): | |
return variance ** 0.5 | |
variance = x_variance(x_input) | |
print x_std_deviation(variance) | |
print x_sum(x_input) | |
print x_average(x_input) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment