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
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 |
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
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) |
NewerOlder