Bug in likelihood fitting

From: Gerco Onderwater (onderwat@nialas.npl.uiuc.edu)
Date: Sat Sep 25 1999 - 01:49:31 MEST


Hi Rooters,

When I was trying to calculate the NDF of my fitting function and compared
it to the NDF returned by TF1::GetNDF(), I noticed that they were
different. I traced this down to the following few lines in H_H1.cxx:

            if (Foption.W1) {
               if (cu == 0 && flag == 2) continue;
               eu = 1;
            } else {
               eu  = hfit->GetBinError(bin);
               if (eu <= 0) continue;
            }

in both H1FitChisquare and H1FitLikelihood. I can believe that such a
check is needed for chisquare minimization, but it definitely doesn't
belong in the likelyhood calculation!!!! Bins with zero counts also have
an error of zero (by definition: sqrt(N)), but that is only relevant for
minimization schemes based on the error!!

This means that all fitting procedures using the log(l) minimization done
so far are meaningless!

Demo:

TF1* f = new TF1("f","gaus",-10,10)
f->SetParameters(100,0,1)
TH1D* h = new TH1D("h","h",100,-10,10)
h->Eval(f,"S")
h->Fit("f","L")                          
h->GetFunction("f")->GetNumberFitPoints()

This will return 32 instead of the expected and correct 100.

Please update this!!

-- Gerco

Dr. C.J.G. Onderwater
Nuclear Physics Laboratory
312 Loomis Laboratory of Physics
University of Illinois at Urbana-Champaign
1110 West Green Street
Urbana, IL 61801-3080     
Phone : (217) 244-7363
Fax   : (217) 333-1215  
E-mail: onderwat@uiuc.edu



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:40 MET