最大值,最小值,平均值,标准差的计算

时间:2022-12-26 15:12:35

用numpy函数可实现快速计算

n [23]: import numpy as np

In [24]: data = [1, 2, 3]

In [25]: np.mean(data)
Out[25]: 2.0

In [26]: np.sum(data)
Out[26]: 6

In [27]: np.max(data)
Out[27]: 3

In [28]: np.min(data)
Out[28]: 1

In [29]: np.std(data)
Out[29]: 0.81649658092772603
In [32]: data = np.array([1, 2, 3])

In [33]: data.min()
Out[33]: 1

In [34]: data.max()
Out[34]: 3

In [35]: data.std()
Out[35]: 0.81649658092772603

In [36]: data.mean()
Out[36]: 2.0