RooFit : Fitting RooDataHist (probably) not using the correct likelihood formula

RooFit has both the binned and unbinned likelihood coded into RooNLLVar. This is triggered by setting the binnedL boolean flag on the last argument of RooNLLVar. RooNLLVar is constructed by RooAbsPdf but the binned likelihood flag is never used (Line 1081 and 1091). I suspect RooAbsPdf always uses the unbinned likelihood formula regardless of input data type.

I tried adding debugging messages in my local ROOT installation source code, in binned likelihood if-branch of RooNLLVar:


and in the unbinned likelihood else-branch:

I tested them with a simple script (testBinned.C (398 Bytes) ). From stdout, it seems RooFit was using an unbinned likelihood when fitting to a RooDataHist object:

This code path is used when you set:

pdf->setAttribute("BinnedLikelihood");

It should be a speed optimisation, though. Also without it the code should converge to the right minimum, but slower.

I tried this code block:

void testBinned(){
RooRealVar x(“x”, “x”, -10, 10);
RooRealVar mu(“mu”, “mu”, 0, -1, 1);
RooRealVar sigma(“sigma”, “sigma”, 1, 0, 10);
RooGaussian gauss(“gauss”, “gauss”, x, mu, sigma);
auto data = gauss.generate(RooArgSet(x), 10000);
RooDataHist hist(“hist”, “hist”, RooArgSet(x), *data);
gauss.setAttribute(“BinnedLikelihood”);
gauss.fitTo(hist);
}

but still I get this result

Yes, I missed something. The speed optimisation is used only if

  1. The BinnedLikelihood flag is set
  2. and the PDF is a RooRealSumPdf.

Hi,
When evaluating the likelihood RooFit uses the same code for binned and unbinned. It treats the binned case as N(ibin) events all located at the bin center.
This is normally fine, but in same case, function varying a lot within a bin, can cause a small bias.

See https://sft.its.cern.ch/jira/browse/ROOT-3874

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.