import numpy as np a = [1,2,3,4,5,6] #求均值 a_mean = np.mean(a) #求方差 a_var = np.var(a) #求标准差 a_std = np.std(a,ddof=1) print("平均值为:%f" % a_mean) print("方差为:%f" % a_var) print("标准差为:%f" % a_std)
其中,可以添加参数axis 如下:
#参数0代表对每一列求值, #参数1代表对每一行求值, #无参数则求所有元素的值 x_mean = np.mean(x,axis = 0) x_var = np.var(x,axis = 0)