TH1F, changing std

Hello,
I have root version 6.09/02. I drew TH1F histogram with this code:

TCanvas *c = new TCanvas(“c”, “histogram”, 600, 400);
TH1F *h4=new TH1F(“h1”,"",1000,5,6);
h4->Fill(5.413935);
h4->Fill(5.482211);
h4->Fill(5.452343);
h4->Fill(5.408871);
h4->Fill(5.454826);
h4->Fill(5.423234);
h4->Fill(5.394764);
h4->Fill(5.40031);
h4->Fill(5.441931);
h4->Fill(5.432928);
h4->Draw();

This code gives me a correct value of std parameter, but when I zoom (I put the cursor on the x axis and scroll with the mouse wheel) the x axis just a little (so I don’t lose any data), the value of std changes. When I unzoom the x axis, the value doesn’t change back. Can you advice me?

Thanks!

This is a known issue of the histogram, because in the first case the statistics is computed at filling time. After setting a range it will be computed using the bin cemters.

If you call. after filling h.ResetStats() you will get the same Mean/RMS values

The original std-deviation is based on the actual values passed to the Fill function. Since the histogram records only the number of entry per bin and does not record each and every value passed to Fill (for that you ought to use a TTree), upon any recalculation of the statistic it can only use the bin center as a substitute. for the input values.

Thank you very much! :slight_smile:

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