Negative log-likelihood from RooHistPdf is always zero

Greetings,

I find that when I ask a RooHistPdf for the negative log-likelihood (NLL) of a given dataset, that the value is always zero. I do, contrarily, find non-zero NLLs for analytic pdfs.

Attached is a proof-of-concept macro. In it I produce a Gaussian data sample, two pdfs – one a RooHistPdf and one a RooGaussian – from the full data sample, generate some toy MC, and then ask each pdf for the NLL given the toy MC. The RooHistPdf returns an NLL of zero while the RooGaussian returns a non-zero NLL.

I’ve seen an old post where seemingly the same behavior is afoot:

[url]RooFit accessing p.d.f's

but the thread appears to have stagnated.

Is there something strange going on here or do I misunderstand something conceptually about these objects and methods? Incidentally I’m working with ROOT v5.26/00c on Linux. Any help appreciated,

Jake
histpdfexample.C (1.04 KB)

Hi Jake,

Thanks for the example. I’ve found the problem: you’ve constructed a (likelihood) function without any parameter. This is conceptually entirely legitimate, but something I had foreseen in the RooAbsArg caching logic. Thus your function is erroneously treated as a variable and the internal cache is never updated, hence
the return value of zero.

The problem is specific to likelihood objects with zero parameters. I’ve added a fix to RooAbsOptTestStatistic in SVN to always treat likelihood etc as functions and this fixes your problem. In ROOT 5.26 you can work around this by declaring a dummy server link to the likelihood function object, e.g.

RooAbsReal* nll = hpdf.createNLL(*d1000) ;
nll->addServer(m) ;
cout << nll->getVal() << endl ;

Wouter