簡體   English   中英

python直方圖如何找到頻率最大的bin的中點

[英]python histogram how to find the midpoint of bin with the maximum frequency

我想找到頻率最高的 bin 的中點。 我如何獲得價值?

使用 matplotlib 我用代碼繪制直方圖:

num_bins = 25
weights = (1 / data['day'].shape[0]) * np.ones_like(data['day'])
n, bin_cuts, patches = plt.hist(data['day'], num_bins, weights=weights)

並得到這個 25 個 bin 的直方圖。 我使用 .max() 但它給出了整個數據的唯一最大點。

嘗試使用 -

0.5 * ( edges[1:] + edges[:-1] ) 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM