Re: [ROOT] Mean value replacing

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Nov 23 2001 - 21:54:54 MET


Replace the line:
one->SetBinContent(i,i);
by
one->Fill(i,i);

Rene Brun


On Fri, 23 Nov 2001, Roman Vassiliev wrote:

> Hello ROOTers!
>  
> In macro below histogram "one" filled by SetBinContent. As a result
> histogram has a wrong values of the Mean and Entries.
>  
> How I can replace wrong value of Mean in this histogram?
> 
> My root version is 3.01/06.
>  
> Thank you.
> Roman Vassiliev.
> 
>  
> {
> 
> gROOT->Reset();
>  
>     Int_t  i, Integral=0;
>     Double_t Mean = 0, RMS = 0,;
>  
>    TH1S *one   = new TH1S("one","one",4, 0.0,4.000001);
>  
>    for (i = 1; i<5; i++)
>         {
>           Integral = Integral + i;
>           Mean = Mean + i*i;
>          RMS = RMS + i*i*i;
>           one->SetBinContent(i,i);
>         }
>  
>      Mean = Mean/Integral;
>      RMS  = RMS/Integral;
>  
>  Printf("Integral:%d Mean:%f RMS:%f",Integral, Mean,
>  sqrt(RMS-(Mean*Mean)));
>  one->Draw();
> }
> 



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