Skip to content

Instantly share code, notes, and snippets.

View jrovegno's full-sized avatar

jrovegno jrovegno

View GitHub Profile
@jrovegno
jrovegno / std.py
Created May 13, 2012 21:05
standard deviation of the values
from math import sqrt
sum, sum2, n = 0.0, 0.0, 0.0
with open("numeros.txt") as infile:
for line in infile:
k = float(line)
sum += k
sum2 += k*k
n += 1
@jrovegno
jrovegno / std2.py
Created May 13, 2012 01:20
standard deviation of the values
import numpy as np
def std2(x):
sum, sum2, n = 0.0, 0.0, 0.0
for k in x:
sum += k
sum2 += k*k
n += 1
return sum2/n - sum*sum/(n*n)