Skip to content

Instantly share code, notes, and snippets.

@kurasaiteja
Last active August 12, 2020 14:58
Show Gist options
  • Save kurasaiteja/f1e27178e5c9d46ae174a5a8f37d0f58 to your computer and use it in GitHub Desktop.
Save kurasaiteja/f1e27178e5c9d46ae174a5a8f37d0f58 to your computer and use it in GitHub Desktop.
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