Last active
August 12, 2020 14:58
-
-
Save kurasaiteja/f1e27178e5c9d46ae174a5a8f37d0f58 to your computer and use it in GitHub Desktop.
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 variance(array): | |
mean = sum(array) / len(array) | |
distances = [] | |
for value in array: | |
# appending square of distances | |
distances.append(((value - mean)**2)) | |
return sum(distances) / len(distances) | |
input = [1,1,1,1,1,1,1,1,1,21] | |
v= variance(input) | |
# Output - 36 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment