赞
踩
总体:
样本:
总体:
- import numpy as np
- data1 = [25,15,13,26,31,17,16,4,41,12]
- data2 = [18,17,23,25,12,27,26,25,22,11]
- data3 = [7,18,12,9,32,29,21,22,13,14]
- print(np.std(data1), np.std(data2), np.std(data3))
10.207840124139876 5.499090833947008 7.874642849044012
样本:
- import numpy as np
- data1 = [25,15,13,26,31,17,16,4,41,12]
- data2 = [18,17,23,25,12,27,26,25,22,11]
- data3 = [7,18,12,9,32,29,21,22,13,14]
- print(np.std(data1,ddof=1), np.std(data2,ddof=1), np.std(data3,ddof=1))
10.760008261045982 5.796550698475775 8.300602387778852
总体:
- data1 = [25,15,13,26,31,17,16,4,41,12]
- data2 = [18,17,23,25,12,27,26,25,22,11]
- data3 = [7,18,12,9,32,29,21,22,13,14]
- # 求平均值
- avg1 = sum(data1)/len(data1)
- avg2 = sum(data2)/len(data2)
- avg3 = sum(data3)/len(data3)
- data11 = list(map(lambda x: x - avg1, data1))
- data22 = list(map(lambda x: x - avg2, data2))
- data33 = list(map(lambda x: x - avg3, data3))
- data111 = list(map(lambda x: x**2, data11 ))
- data222 = list(map(lambda x: x**2, data22 ))
- data333 = list(map(lambda x: x**2, data22 ))
- c1 = math.sqrt(sum(data111 )/len(data1))
- c2 = math.sqrt(sum(data222 )/len(data2))
- c3 = math.sqrt(sum(data333 )/len(data3))
- print(c1, c2, c3)
10.207840124139876 5.499090833947008 7.874642849044013
样本:
- data1 = [25,15,13,26,31,17,16,4,41,12]
- data2 = [18,17,23,25,12,27,26,25,22,11]
- data3 = [7,18,12,9,32,29,21,22,13,14]
- # 求平均值
- avg1 = sum(data1)/len(data1)
- avg2 = sum(data2)/len(data2)
- avg3 = sum(data3)/len(data3)
- data11 = list(map(lambda x: x - avg1, data1))
- data22 = list(map(lambda x: x - avg2, data2))
- data33 = list(map(lambda x: x - avg3, data3))
- data111 = list(map(lambda x: x**2, data11 ))
- data222 = list(map(lambda x: x**2, data22 ))
- data333 = list(map(lambda x: x**2, data33 ))
- c1 = math.sqrt(sum(data111 )/(len(data1)-1))
- c2 = math.sqrt(sum(data222 )/(len(data2)-1))
- c3 = math.sqrt(sum(data333 )/(len(data3)-1))
- print(c1, c2, c3)
10.760008261045982 5.796550698475775 8.300602387778854
- import numpy as np
- np.mean() # 可以用来求平均值
- np.sum() # 可以用来求和
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。