# Reliable integrals in RooFit for dimension > 2

Dear Experts,
can you please tell me whether the integrals in RooFit for pdf dimension > 2 are reliable.

Is it true that you guarantee precision for all 1D pdfs and generally for most 2D pdfs,
but not for dim(pdf) > 2D pdfs ?

Kind regards,

• Mauro.

Dear Mauro,

while Iâ€™m not too much of an expert on the numerical integration code in RooFit, Iâ€™ve done my share of numerical and analytical integrations, and the bottom line of that experience is â€śit dependsâ€ť. If you integrand is well behaved (a few times differentiable), and has neither discontinuities nor poles in the integrand or its derivatives, nor is it oscillating quickly, there is an excellent chance that the routines that come with RooFit will do a sterling job. In general, without access to your PDF (and how you use it), itâ€™s impossible to tell how â€śreliableâ€ť the integration is. Nevertheless, I append a few fairly generic comments:

If you have one of these problematic integrands, it depends on how clever the integration routine is, and often it is not clever enough, or far too slow to converge to something reasonable. In these cases, your best bet is to stare long and hard at your PDF to see if you can do some part of the integration analytically. RooFit allows user-defined PDF classes to provide its own integration routines, and doing so in cases where itâ€™s possible generally increases speed and numerical stability.

What Iâ€™ve written so far is true for 1D and higher dimensional integrals. For more than one dimension, though, one has to realise that the general case of n-dimensional is really hard (and quite slow). If you can somehow break it down to integrals that factorise, you should do so (and RooFit is clever enough to figure that out in many cases). If you suspect you have problems with this, I recommend you read up on it in some book about numerical maths - understanding the method and its limitations will help you diagnose the pitfallsâ€¦

I realise these are fairly generic comments. Maybe others have a better/more accurate/more helpful set of comments - if so, please come forward. Otherwise, feel free to let me know if you need a couple of pointers (once youâ€™ve figured out which part you can do analytically)â€¦

Cheers,

Manuel

Dear Manuel,

I believe that we meet the requirements of continuity that you are referring to.
Though Iâ€™m afraid our problem is not factorizable.

But we do have a peculiar problem to face, which has the following characteristics:
(a) the pdf domain is 3D in cos(alpha) - defined between -1 and 1, cos(beta) - defined between 0 and 1, and gamma - defined between 0 and pi.
(b) the parameter space is not well-behaving in the sense that for some values of the parameters the pdf becomes negative at certain points of the domain [cos(alpha), cos(beta), gamma]. Unfortunately the sub-space of the parameters that allows to have an always positively defined pdf is not trivial (i.e. it is not a hyper-rectangle)

I understand that itâ€™s difficult to make general statements about these problems, I was wondering whether some had encountered suspicious behaviour of the RooFit integration in similar circumstances.

Many thanks again.

• Mauro.
1 Like

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