Issue
I am confused. I found few formulas for finding the SD (standard deviation
).
This is the NumPy
library std
method:
>>> nums = np.array([65, 36, 52, 91, 63, 79])
>>> np.std(nums)
17.716909687891082
But I found another formula here:Standard deviation
By this formula with the same dataset my result is 323,1666666666667
. Now which one is right? Or they are used for two different things?
EDIT: Seems I forgot about the square root
Solution
numpy is correct, of course. here the plain python version:
from math import sqrt
data = [65, 36, 52, 91, 63, 79]
mean = sum(data) / len(data)
std = sqrt(sum((d - mean) ** 2 for d in data) / len(data))
print(std) # 17.716909687891082
Answered By - hiro protagonist
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.