Means from TPaveStats Window and from GetMean() differ

I finally understood, that the two values depend slightly on the range, in which you plot your TH1F histo. As in my script I ask for the mean and RMS after changing the X-axis range with h1->GetXaxis()->SetRange(int lowest_bin, int highest_bin), while the TPaveStats values are set as soon as the histogram is filled, the values change a little. I still wonder why, as I always took care to draw all bins with content and I never rebinned or something… And I wonder which one are the valid values.

Hi everyone,

I have the following problem: I draw some TH1F histos and use the GetMean() function on them. I fill those values into a THF2 histo with SetBinContent(xbin, ybin, mean) and get it printed with the text option.
The values shown are a little bit different from the one the TPaveStats Window shows for the single TH1 histos. All histos are drawn in their full range. The difference is small, e.g. 517.093 from GetMean() and 517.6 in the TPaveStats. Could that be some floating point precision error? It doesn’t work any better by using TH1D resp. TH2D histos.
How could I solve this and which one is the “correct” mean?

Best regards

Can you provide a small script showing the problem ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.