Dear Rooters,
I am running the included macro. The goal is to extract the likelihood value (or log likelihood, doesn't matter).
If fitting using chi2, using:
TVirtualFitter *fitter = TVirtualFitter::Fitter(hWimp);
Double_t amin,edm,errdef;
Int_t nvpar,nparx;
fitter->GetStats(amin,edm,errdef,nvpar,nparx);
Double_t chi2 = hWimp->GetFunction("fitSignal")->GetChisquare();
printf("amin=%g, chi2=%g\n", amin, chi2);
I get:
amin=51.689, chi2=51.689
.. which makes sense.
If fitting using LL (log likelihood), I get:
> amin=502.46, chi2=857560
The obtained fit parameters are similar (though the likelihood fit did not catastrophical fail), I would have expected the chi2 to be similar to the one obtained in the first case. Furthermore in
http://root.cern.ch/root/roottalk/roottalk00/1963.html
Rene says that amin = -2 logL. Is that really true ?
I am using ROOT v5.10/00 on
Scientific Linux CERN SLC release 4.2 (Beryllium)
Linux 2.6.9-22.0.1.EL.cern
cheers, thanks,
Jan
ToyLL(){
////////////////////////////////////////////////////////// // // Jan Conrad (Stockholm University), conrad_at_physto.se//
//////////////////////////////////////////////////////////
Int_t nBinsChi2 = 50;
// generate histogram with E-2 spectrum
TH1F* hWimp = new TH1F("wimp","wimp",nBinsChi2,1e4,1e6);
// Powerlaw (function 1)
TF1 *f1 = new TF1("f1","(x/1.e5)**(-2.0)",1e4.,1e6);
// Double exponential (function 2).
TF1 *f2 = new TF1("f2","TMath::Exp(-1.e-5*x)",1e4,1e6);
Double_t WimpSpec(Double_t *x, Double_t *par) { return par[0]*TMath::Exp(par[1]*x[0]); }
hWimp->Reset();
for (Int_t iExp=0; iExp<1000000; iExp++) {
double ws = f2->GetRandom(); hWimp->Fill(ws);
hWimp->Sumw2();
// check signal fitting
TF1 *fitSignal = new TF1("fitSignal",WimpSpec,1e4.,1e6,2);
fitSignal->SetNpx(500); fitSignal->SetLineWidth(4); fitSignal->SetLineColor(kMagenta); fitSignal->SetParameters(1.e4,-1.e-4);
TVirtualFitter *fitter = TVirtualFitter::Fitter(hWimp);
Double_t amin,edm,errdef;
Int_t nvpar,nparx;
fitter->GetStats(amin,edm,errdef,nvpar,nparx);
Double_t chi2 = hWimp->GetFunction("fitSignal")->GetChisquare();
printf("amin=%g, chi2=%g\n", amin, chi2);
}
This archive was generated by hypermail 2.2.0 : Wed Jul 18 2007 - 17:50:01 CEST