Skip to content

Instantly share code, notes, and snippets.

@jrovegno
Created May 14, 2012 15:34
Show Gist options
  • Save jrovegno/2694601 to your computer and use it in GitHub Desktop.
Save jrovegno/2694601 to your computer and use it in GitHub Desktop.
standard deviation of the values
from math import sqrt
sum, sum2, n = 0.0, 0.0, 0.0
f = open('numeros.txt', 'r')
numbers = f.readlines()
f.close()
for num in numbers:
k = float(num)
sum += k
sum2 += k*k
n += 1
print sqrt(sum2/n - (sum/n)**2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment