Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RF] Inconsistency when normalizing pdf over non-dependent parameter #17371

Open
guitargeek opened this issue Jan 8, 2025 · 0 comments
Open

Comments

@guitargeek
Copy link
Contributor

guitargeek commented Jan 8, 2025

When passing a normalization set to RooAbsPdf::getVal(), the auto-normalization over the parameters that the pdf doesn't directly depend on is skipped:

Demonstrator:

RooRealVar x{"x", "", 0.0, -10., 10.};
RooRealVar c{"c", "", 1.0, -10., 10.};

RooArgSet normSet{x};

RooGenericPdf pdf{"pdf", "", "c", {c}};

// Adding a dummy dependency on X triggers correct normalization
// RooGenericPdf pdf{"pdf", "", "c + x - x", {c, x}};

std::unique_ptr<RooAbsReal> pdfInteg{pdf.createIntegral(normSet)};

std::cout << "manual normalization : " << (pdf.getVal() / pdfInteg->getVal()) << std::endl;
std::cout << "auto normalization   : " << pdf.getVal(normSet) << std::endl;

The output is:

manual normalization : 0.05
auto normalization   : 1

This is not mentioned anywhere in the docs.
People expect that normalization is done over every parameter in the normSet, and if there is no mathematical dependency, it will divided by the uniform integral, just like createIntegral() does it.

This is regularly tripping up our users, like in this forum post where the person tried to normalize manually instead. Also from private chat with @will-cern, I know he had the same confusion before. A common workaround is the "dummy-dependency", as shown in the reproducer code.

I understand why it was implemented like that: it makes bookkeeping of observables in simultaneous pdfs easier, because then the caller doesn't need to worry about restricting the observables to the ones relevant for the current category. The caller is here usually some other implementation detail of RooFit, like the test statistics or plotting.

So I think it's not too late to make the normalization behavior more intuitive by not dropping non-dependent parameters and adapting the RooFit internals accordingly.

@guitargeek guitargeek self-assigned this Jan 8, 2025
@guitargeek guitargeek changed the title [RF] Inconsistency when normalizing pdf over non-dependent [RF] Inconsistency when normalizing pdf over non-dependent parameter Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant