matplotlibのヒストグラムを使用すると、ビンの数を選択できます。 しかし、どのようにnumpyのヒストグラムでビンの数を選ぶことができますか?numpy.histogramのビン数を選択する方法は?
import matplotlib.pyplot as plt
import numpy as np
array = [1,3,4,4,8,9,10,12]
range = int((max(array)) - min(array))+1
x, bins, patch = plt.hist(array, bins=range)
この場合
範囲=ビンの数=(12-1)+1 = 12
その結果は、x = [1 0 1 2 0 0 0 あります。1. 1. 1. 0 1]
しかしnumpyの結果は
hist, bin_edges = np.histogram(array, density=False)
numpyの= [1 1 2 0 0 0 1 1 1 1] numpy_bin = [1 2.1であります3.2 4.3 5.4 6.5 7.6 8.7 9.8 10.9 12.]
numpyのを使用して、どのように私はビンの数(= INT((MAX(配列)) - 分(配列))+ 1)を選択することができ、私はmatplotlibのように同じ結果が欲しい
を
'bincount'を使う:' np.bincount(array) '? – Divakar