Re: [ROOT] Inconsistency of mean calculations in TH1

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Mar 01 2001 - 18:52:41 MET


Hi Tom, Till,

Where do you see the bug ?????

Computing the mean value/rms of an histogram by using the bin center
is a very crude approximation. In the case of Root:
 - During the Histogram Fill process, several statistical quantities
   are incremented (see TH1 members :
    Stat_t        fTsumw;           //Total Sum of weights
    Stat_t        fTsumw2;          //Total Sum of squares of weights
    Stat_t        fTsumwx;          //Total Sum of weight*X
    Stat_t        fTsumwx2;         //Total Sum of weight*X*X
   and the equivalent fot TH2 and TH3.

There are obviously cases where the above parameters are not available, eg
when you SetBinContent yourself. In this case, Root uses the poor man approach
of computing these quantities using the bin center only.

Rene Brun


Till Neunhoeffer wrote:
> 
> Hi all,
> 
> we have done the following:
> 
> 1) Create some histogram a and fill it
> 2) create an identical histogram b
> 3) for each bin in a, fill a->GetBinContent in the corresponding bin of b
> 
> For all we know, these histograms should be identical.
> 
> Yet their means and RMS differ.
> 
> This seems to derive from the fact that when filling the histogram a, its
> mean gets calculated with the actual x value at which we fill and not with
> the center of the corresponding bin.
> 
> Is this a bug or a feature?
> 
> Thanks
> Tom and Till



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET