2013-10-07 20 views

回答

1

假設你正在使用numpy的和matplotlib,你可以得到垃圾桶邊和計數使用np.histogram(),然後用pp.errorbar()繪製它們:

import numpy as np 
from matplotlib import pyplot as pp 

x = np.random.randn(10000) 
counts,bin_edges = np.histogram(x,20) 
bin_centres = (bin_edges[:-1] + bin_edges[1:])/2. 
err = np.random.rand(bin_centres.size)*100 
pp.errorbar(bin_centres, counts, yerr=err, fmt='o') 

pp.show() 

enter image description here

我不知道你是什麼意思是「歸一化」,但是很容易,例如,將計數除以總數值,以便直方圖總和爲1.

對我來說更大的問題是錯誤條實際上是意思是在一個直方圖的上下文中,您正在處理每個bin的絕對計數。