Re: [ROOT] binomial errors in TH1F

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Oct 19 2000 - 22:17:49 MEST


Hi Mikhail,
Add the statement h1f->Sumw2() after the creation of the histogram. See
the code below

Rene Brun

On Thu, 19 Oct 2000, Mikhail Jabitski (Zhabitsky) wrote:

> 
> 	Hello ROOTers!
> 
> I have a histogram which is the ratio of two correlated histograms.
> I used TH1F::Divide(TH1 *h1, TH1 *h2, Double_t c1, Double_t c2, Option_t 
> *option); with option="B" to get the resulting distribution with binomial
> errors. But it seems that calculated errors are not binomial.
> Example below illustrates this problem.
> Am I doing something wrong?
> 
> 	Mikhail
> 
> PS
>  I use 
>   *   Version   2.25/03 15 September 2000   *
> CINT/ROOT C/C++ Interpreter version 5.14.50, Sep 2 2000
> 
> 
> {
>    gROOT->Reset();
>    c1 = new TCanvas("c1","The FillRandom example",200,10,700,900);
> 
>    gaus1 = new TFormula("gaus1","gaus");
>    gaus1->SetParameters(1000,10,1);
> 
>    h1f = new TH1F("h1f","Test random numbers",200,0,20);
     h1f->Sumw2();   //<============================
>
h1f->FillRandom("gaus1",10000);
> 
>    TH1F *bindistr = new TH1F("binomial","Test binomial",200,0,20);
>    bindistr->Divide(h1f,h1f,1.0,2.0,"B");
> 
> /*  
>    Int_t nbinsx = h1f->GetNbinsX();
>    Double_t w, n2;
>    for (Int_t binx=0; binx<=nbinsx+1; binx++)
>    {
>     w = bindistr->GetBinContent(binx);
>     n2 = h1f->GetBinContent(binx);
>     if (n2)
>      bindistr->SetBinError(binx,sqrt(w*(1-w)/n2));
>     else
>      bindistr ->SetBinError(binx,0.0);  
>    };
> */
>    
>    bindistr->Draw("E");
>    c1->Update();
> }
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:35 MET