【統計学】ヒストグラム(Python)
前回作成した度数分布表をもとにヒストグラムを書いてみます。
import pandas as pd import matplotlib.pyplot as plt #データ読込 data = pd.Series([ 154,196,190,28,122,78,150,99,72,117, 73,195,3,62,190,125,7,63,182,56, 7,29,56,104,154,12,117,63,90,176, 101,168,47,99,69,124,55,173,115,71, 93,31,66,21,5,155,8,54,131,146, 54,160,10,59,140,103,40,23,125,35, 170,145,148,109,22,60,63,13,167,111, 125,78,97,130,118,140,29,156,146,94, 98,12,78,171,161,71,96,198,170,177, 145,5,197,186,15,95,30,162,165,108 ]) plt.hist(data, bins=8) #binsで階級の数を設定する。設定しなければ自動化される plt.title("Histgram") #図のタイトル plt.xlabel("x") #x軸のラベル名 plt.ylabel("frequency") #y軸のラベル名 plt.show()
これからもデータが一様に分布していることがわかる。