Hi everybody, I posted the next lines into roottalk@cern.ch already, Pere told me I should rather use the forum for question of that kind:
Dear ROOTers,
Today I recognized something in root and I am not sure if it is a
feature or a bug! Please see the attached example. Both charts look
identical by the means are different
I always thought that the mean-value which is written in the stat box
above a histogram (or reachable by GetMean()) relies on the discrete
values of the histogram bins. I checked the source code and indeed the
mean and also the RMS is calculated by using the individual values used
in the Fill-command (which have usually a much finer resolution than the
bin-width).
This is interesting, because I always thought, one could use a histogram
to calculate a performance record (german: Notenspiegel or
Klassenspiegel) - like 6 people have a grade between 1 and 2, 10 between
2 and 3, and so on. It seems this is not possible. By calculating the
performance record you have to use the BinCenter-Value of each bin and
its content, but not the full resolution of every value.
I’m 99% sure that this is a feature, not a bug (can’t believe that this
was not discovered since 10 years :-p). But from the doc it does not
come clear that GetMean() is not calculated from the content of the
bins, bot from the value entered in the Fill-method.
Is there an easy way to calculate the mean based on the BinCenter
values? (without looping over all bincontents from outside the TH1-class)
Georg
getMean.C (633 Bytes)