NumPy⑧ (最大値、最小値、分散、標準偏差)

最大値、最小値、分散、標準偏差

NumPyでは、最大値や最小値、平均、分散など、基本的な統計量を求める関数が用意されています。

  • max()
    配列要素の最大値を返す。
  • min()
    配列要素の最小値を返す。
  • mean()
    配列要素の平均値を返す。
  • var()
    配列要素の分散を返す。
  • std()
    配列要素の標準偏差を返す。
  • argmax()
    最大値の要素のインデックスを返す。
  • argmin()
    最小値の要素のインデックスを返す。

[Google Colaboratory]

1
2
3
4
5
6
7
8
import numpy as np
x = np.array([35, 40, 45, 50, 55, 60], dtype = np.float)

print('最大値 : ', np.max(x))
print('最小値 : ', np.min(x))
print('平均値 : ', np.mean(x))
print('分 散 : ', np.var(x))
print('標準偏差: ', np.std(x))

[実行結果]