Here is my favourite example of the confusing behaviour of TH1::GetMean():
root [0] TH1F* h2=new TH1F("foo2", "bar", 10, 0, 5)
root [1] h2->Fill(2.2)
root [2] h2->GetMean()
(const Double_t)2.20000000000000018e+00
// This excludes a zero bin, so shouldn't affect the mean: root [3] h2->GetXaxis()->SetRangeUser(-1, 3.8)
root [4] h2->GetMean() (const Double_t)2.25000000000000000e+00
On Tuesday, September 13, 2011 04:16:05 PM Arthur E. Snyder wrote:
> Stefan and Aammer:
>
>
> What would be nice would be an option, e.g., GetMean("binned") vs.
> GetMean("unbinned") with default being what folks are used to.
>
> I suspect that problem occurs not just for subtracted historgrams but for
> weighted ones.
>
> On the other hand sometimes you want the unbinned mean. If you've made big
> bins to make the plot look nice, the mean may be seriously over estimated
> by using middle of the bin ...
>
> Maybe there should be a warning when |h->Sumw2()| has been involked ...
>
> -Art S.
>
> A.E. Snyder, The Former Group C (TFC) \!c*p?/
> SLAC Mail Stop #95 ((. .))
> Box 4349 |
> Stanford, Ca, USA, 94309 '\|/`
> e-mail:snyder_at_slac.stanford.edu o
> phone:650-926-2701 _
> http://www.slac.stanford.edu/~snyder BaBar
> FAX:707-313-0250 Collaboration
> &
> Fermi/GLAST
>
> On Tue, 13 Sep 2011, Stefan Piperov wrote:
> > This issue - that ROOT reports histogram's momenta based on unbinned
> > data - has been discussed several times now, but without much
> > consequences...
> >
> > It is plain wrong, of course, to report quantities related to the
> > initial dataset as belonging to the histogram, but this is how ROOT was
> > designed from the very beginning, so it's too late now to change, I
> > guess. What we can do, though, is to spread the word, so that at least
> > the users know of this problem, and do not rely on TH1::GetMean() to get
> > the mean of the binned data.
> >
> > Stefan.
> >
> > On Tue, 13 Sep 2011, Arthur E. Snyder wrote:
> >> Aamer,
> >>
> >> It doesn't work on subtracted histograms. I had to 'roll-my-own' to do
> >> that (though there might be something existing that does this that I
> >> just didn't find).
> >>
> >> As I recall |root] does unbinned mean, so you get the same result
> >> regardless of binning. It's not clear what it does the case of
> >> subtracted histograms, but if the histograms is asymmetric the result
> >> can be wildly wrong.
> >>
> >> -Art S.
> >>
> >> A.E. Snyder, The Former Group C (TFC) \!c*p?/
> >> SLAC Mail Stop #95 ((. .))
> >> Box 4349 |
> >> Stanford, Ca, USA, 94309 '\|/`
> >> e-mail:snyder_at_slac.stanford.edu o
> >> phone:650-926-2701 _
> >> http://www.slac.stanford.edu/~snyder BaBar
> >> FAX:707-313-0250 Collaboration
> >>
> >> &
> >>
> >> Fermi/GLAST
> >>
> >> On Tue, 13 Sep 2011, Aamer Wali Rauf wrote:
> >>> Hi,
> >>> I have always assumed (and thus used) that the TH1::GetMean(1) method
> >>> gives out the weighted mean value
> >>> of the x-axis of the histogram. Visibly it looks to me that way but is
> >>> it really so? Can someone
> >>> comment on that please?
> >>>
> >>> Thanks in advance,
> >>> Aamer
> >
> > *---------------------------------------------------------------------*
> >
> > Stefan Piperov Mail: FNAL P.O.Box 500, MS 205, Batavia, IL-60510
> > Phone: (630) 840-5176 E-Mail: piperov_at_fnal.gov
> >
> > *---------------------------------------------------------------------*
> > "Give a skeptic an inch... and he'll measure it."
Received on Tue Sep 13 2011 - 22:49:41 CEST
This archive was generated by hypermail 2.2.0 : Wed Sep 14 2011 - 11:50:01 CEST