Skip to content

Instantly share code, notes, and snippets.

@onejohi
Created November 7, 2022 19:49
Show Gist options
  • Save onejohi/b9f882f6db6196d0be8ca73fb27262a4 to your computer and use it in GitHub Desktop.
Save onejohi/b9f882f6db6196d0be8ca73fb27262a4 to your computer and use it in GitHub Desktop.
# This is a custom made Python function/method I made that accepts an array value and calculates the variance
def variance(array_value):
sum = 0
for i in array_value:
sum += i
mean = sum / len(array_value)
difference_value = 0
for j in array_value:
difference = mean - j
square_value = difference ** 2
difference_value += square_value
return difference_value / len(array_value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment