MATLAB: How to calculate the errors of histogram

histogram errors errorbar

For example: if we know the data : 'x1, x2, x3,…..xn'
and the errors of these data: 'e1, e2, e3,…, en'
By using 'hist', one can get the histogram, for example, there are 5 bins:
y axies value: 'count1, count2, count3, count4, count5'
x axies value: 'bin1, bin2, bin3, bin4, bin5 '
Then, how to calculate the errors of 'count1, count2, count3, count4, count5', based on 'e1, e2, e3,…, en'?

Best Answer

Just sum the errors that belong to the specific bins: assume in bin1 are counted data x2,x6,x7,x9, then
error_bin1 = e2+e6+e7+e9
and so on for other bins..