chi2/NDF from max. likelihood include bins with 0 counts.

From: Wei Xie <wxie_at_purdue.edu>
Date: Fri, 17 Dec 2010 19:14:43 -0500


When calculating the chi2/NDF, empty bin is taken into account in the max.likelihood method. Least-chi2 option don't have this problem. The following macro demonstrate this. I tried this in ROOT 5.22. 5.27. They shows the same results. Is this because I didn't use it properly or this is a bug? If this is not a bug, how to do the max. likelihood fit without taking into account the empty bins?

Thanks
--Wei

{

     h = new TH1F("h", "", 100, -10, 10);
     for(int i = 0; i<1000; i++) {
         float a = gRandom->Gaus(0, 1);
         h->Fill(a);
     }

     h->Sumw2();

     h->Scale(0.5);

     TH1F *h0 = (TH1F*)h->Clone();
     h0->SetName("h0");
     TH1F *h1 = (TH1F*)h->Clone();
     h1->SetName("h1");
     TH1F *h2 = (TH1F*)h->Clone();
     h2->SetName("h2");

     c1 = new TCanvas("c1", "", 900, 900);
     c1->Divide(2, 2);

     gStyle->SetOptFit(1);

     c1->cd(1);
     h->Fit("gaus", "L", "", -3, 3);
     c1->cd(2);
     h0->Fit("gaus", "L", "", -10, 10);

     c1->cd(3);
     h1->Fit("gaus", "", "", -3, 3);
     c1->cd(4);
     h2->Fit("gaus", "", "", -10, 10);

} Received on Sat Dec 18 2010 - 01:14:50 CET

This archive was generated by hypermail 2.2.0 : Sat Dec 18 2010 - 17:50:01 CET