Rebin TH1D with average

Hi everbody,
I would like to rein a histogram filled with percentages (like 0.45 and so on). Therefor I do not want the bins to be added up when rebinning but rather averaged. Is there an option to do this?

I guess @moneta can help you

If you are plotting averages, maybe what you want to look is the TProfile class. See ROOT: TProfile Class Reference.
Otherwise, please be more specific and possibly provide an example



1 Like

Thank you for your answer. I do not think the TProfile class is right for my problem. I have several histograms which I would like to divide, scale and add. All of them are “normal” histograms but one is filled with values from 0 to 1. I have to rebin all histograms, but the one with values between 0 and 1 should not be added up as usual but rather averaged over the bin merged together. Until now I simply do this “per hand” but was wondering whether there was an option in the “rebin” function to do this

Int_t n = 5; myhisto->Rebin(n); myhisto->Scale(1. / n);

1 Like

Thank you for your reply. I need to calculate the error weighted average, which makes things more complicated. But I have now simply written a short function myself. Still thanks for your help!