2024-10-09 17:02:29 +00:00
|
|
|
import math
|
2024-10-09 17:02:32 +00:00
|
|
|
from _helpers import listInput
|
2024-10-09 17:02:29 +00:00
|
|
|
|
|
|
|
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)))
|
|
|
|
|
2024-10-09 17:02:32 +00:00
|
|
|
nums = listInput('Please input a list of numbers')
|
|
|
|
res = sd(nums)
|
|
|
|
|
|
|
|
print()
|
|
|
|
print('The list:', nums)
|
|
|
|
print('Standard Deviation:', res)
|