chi2/DOF value

Hello all,

I have 2 questions regarding the chi2 value returned by roofit:

  1. I perform a simple extended chi2 fit as follows:

RooRealVar n_sig(“n_sig”,“n_sig”, 10.0, -500.0, 500.0);
RooRealVar n_bkgd(“n_bkgd”,“n_bkgd”, 130.0, -500.0, 500.0);

RooAddPdf sum_PDF(“sum_PDF”, “sum_PDF”, RooArgList(sig_PDF, bkgd_PDF), RooArgList(n_sig, n_bkgd));

//data_hist is a RooDataHist
RooChi2Var chi2(“chi2”,“chi2”,sum_PDF,*data_hist, Extended());

RooMinuit m2(chi2);
m2.migrad();
RooFitResult* fitres1 = m2.save() ;

//The data_hist contains 12 bins, and the only floating parameters are the yields (n_sig & n_bkgd). Since the sum of the yields =1,
//I conclude that the number of free parameters is 1 (correct?). So, to calculate the chi2/DOF, I do the following:
double chi2_val = chi2.getVal();
double red_chi2 = chi2_val/(12-1);

However, the value that I get for chi2_val (and for red_chi2) is very high: ~2.2. If I calculate the chi2 by hand (from the plot), I only get ~1.0.

  1. My second question is in regards to calculating the chi2 for a simultaneous fit. The simultaneous fit is constructed as follows:

RooRealVar f_sig(“f_sig”, “f_sig”, 0.5, 0.0, 1.0);

RooAddPdf PDF_1(“PDF_1”, “PDF_1”, RooArgList(*PDF_1a,*PDF_1b, f_sig);
RooAddPdf PDF_2("PDF_2, “PDF_2”, RooArgList(*PDF_2a,*PDF_2b, f_sig);

RooChi2Var chi2_1(“chi2_1”,“chi2_1”, PDF_1, *HIST_1);
RooChi2Var chi2_2(“chi2_2”,“chi2_2”, PDF_2, *HIST_2);

//I then add the chi2 as suggested by Wouter: root.cern.ch/phpBB2/viewtopic.php?p=24938#24938 (Thanks again!!)
RooAddition chi2_sum(“chi2_sum”,“sum of chi2 terms”,RooArgSet(chi2_1,chi2_2));

RooMinuit m2_sum(chi2_sum);
m2_sum.migrad();
RooFitResult* fitres1 = m2_sum.save();

//Here is where I run into trouble. Each of the two histograms (HIST_1 and HIST_2) contain 5 bins, and the only floated parameter is f_sig.
//So, If I were to follow the logic used in my question above, I would write:
double chi2_val = chi2_sum.getVal();
double red_chi2 = chi2_val/(10-1);

Once again, I get a very high value for chi2_val…

Can anyone please tell me if I am doing something incorrect in either (or both) of the two cases?!

Many thanks in advance,
Pablo

Hi Pablo,

RooChi2Var indeed represents the ‘raw’ chi^2, it is not normalized by the number of degrees of freedom, so if you want to interpret it that way you need to make that division yourself.

Concerning your question of chi^2/ndof for simultaneous fits: I’m not sure if one can simply say that the number of degrees of freedom for simulatenous fits can be calculated you do. This is more of a statistics questions than a software question and I don’t know the answer.

You could gain a bit more insight in this by running a series of toy MC experiments,
and see how the chi^2 distributions comes out for those toys. I’m not sure that you should conclude from a single outcome of 2.2 that it doesn’t work. A value of 2.2 is not
that improbable after all.

Wouter