Skip to content

Conversation

@guitargeek
Copy link
Contributor

Just like for other pdfs that are strictly zero for negative observable values, the integral for xMin < zero should still evaluate correctly (compare for example with the RooLandau).

Addresses this forum report:
https://root-forum.cern.ch/t/roofit-pdfs-with-different-domain-in-the-same-model-e-g-gauss-lognormal/64505/3

Little demo that it works now:

RooRealVar x("x", "x", 0.0, 10.0);
RooRealVar mu("mu", "mu", 1.0);
RooRealVar sigma("sigma", "sigma", 0.5);
RooLognormal logn("logn", "lognormal pdf", x, mu, sigma);

double a = -1.0;
double b = 5.0;

x.setRange("intRange", -1.0, 5.0);

RooAbsReal* integral = logn.createIntegral(x, RooFit::NormSet(x),
                                           RooFit::Range("intRange"));

double result = integral->getVal();

std::cout << "Integral of Lognormal from " << a << " to " << b
          << " = " << result << std::endl;

Just like for other pdfs that are strictly zero for negative observable
values, the integral for xMin < zero should still evaluate correctly
(compare for example with the RooLandau).

Addresses this forum report:
https://root-forum.cern.ch/t/roofit-pdfs-with-different-domain-in-the-same-model-e-g-gauss-lognormal/64505/3

Little demo that it works now:
```c++
RooRealVar x("x", "x", 0.0, 10.0);
RooRealVar mu("mu", "mu", 1.0);
RooRealVar sigma("sigma", "sigma", 0.5);
RooLognormal logn("logn", "lognormal pdf", x, mu, sigma);

double a = -1.0;
double b = 5.0;

x.setRange("intRange", -1.0, 5.0);

RooAbsReal* integral = logn.createIntegral(x, RooFit::NormSet(x),
                                           RooFit::Range("intRange"));

double result = integral->getVal();

std::cout << "Integral of Lognormal from " << a << " to " << b
          << " = " << result << std::endl;
```
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Test Results

    21 files      21 suites   3d 18h 53m 37s ⏱️
 3 786 tests  3 785 ✅ 0 💤 1 ❌
77 534 runs  77 533 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 3721cac.

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
I am not sure why somebody wants to integrate up to negative value, it should not make sense to use a region where the pdf is not defined and it is probably an error in the use case.
The case of the Landau distribution is different, since the Landau is defined and valid for negative values.

@guitargeek
Copy link
Contributor Author

That is true. It's debatable whether a lognormal over a negative domain makes sense. But here we had no choice if we want to be consistent. Evaluating a RooLognormal for x < 0 gives zero and not NaN, so the integral needs to be consistent with that if we don't want to confuse users

@guitargeek guitargeek merged commit 7ffaf51 into root-project:master Dec 11, 2025
31 of 35 checks passed
@guitargeek guitargeek deleted the lognormal branch December 11, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants