the-honk/python/calculators/stdev.py

10 lines
183 B
Python
Raw Normal View History

2024-10-09 17:02:29 +00:00
import math
def sd(x):
n = len(x)
mean = sum(x) / n
squared = [y ** 2 for y in x]
return math.sqrt(abs((sum(squared) / n) - (mean**2)))
print(sd([135,230,132,323]))