-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Batch mode with RooSimultaneous introduces spurious parameters #10991
Comments
Hi, thanks a lot for opening this issue! I was aware of this, and in the next patch release these spurious free parameters will be gone (6.26.06 is expected in about 2 weeks). However, it is still good that you opened this issue because now that you used
So to close this issue for good, we also have to get rid of them in the "Constant Parameter" list. These spurious parameters should not be seen anywhere, as they are pure implementation details for the BatchMode. |
As it is important that the BatchMode has no possible disadvantage compared to the old RooFit, I put this issue into the list of issues that need to be resolved before the next patch release: #10758 |
Hi Jonas I switched to LCG dev3 to test on master and noticed that the fitted parameter value is equal to what it was in 6.26.04+batchmode, so still different from no batchmode or batchmode in 6.24.06 |
No, this is not expected at all. I will investigate this! |
Ah I see now what is going on. In the BatchMode implementation, each RooAbsArg in your model must be unique (this was always preferred in RooFit, but the BatchMode is more strict with that). You are using the same pdf for each component of the RooSimultaneous, and it can't deal with that. This code would work: void test_batchModeCategory() {
RooRealVar x("x", "", 0, 1);
RooRealVar rnd("rnd", "", 0, 1);
// change this mapping from labels to indices to change the fit result (slightly)
RooThresholdCategory catThr("cat", "", rnd, "a", 2);
catThr.addThreshold(1./3, "b", 0);
catThr.addThreshold(2./3, "c", 1);
RooRealVar m("m", "", 0.5, 0, 1);
RooGaussian g1("g1", "", x, m, RooFit::RooConst(0.1));
RooGaussian g2("g2", "", x, m, RooFit::RooConst(0.1));
RooGaussian g3("g3", "", x, m, RooFit::RooConst(0.1));
RooUniform rndPdf("rndPdf", "", rnd);
RooProdPdf pdf("pdf", "", RooArgSet(g1, rndPdf));
auto ds = pdf.generate(RooArgSet(x, rnd), RooFit::Name("ds"), RooFit::NumEvents(100));
auto cat = dynamic_cast<RooCategory*>(ds->addColumn(catThr));
RooSimultaneous sim("sim", "", *cat);
sim.addPdf(g1, "a");
sim.addPdf(g2, "b");
sim.addPdf(g3, "c");
for(bool batchMode : {false, true}) {
sim.fitTo(*ds
, RooFit::Save(true)
, RooFit::PrintLevel(-1)
, RooFit::BatchMode(batchMode) // commenting this solves the issue
)->Print("V");
m.setVal(0.5);
m.setError(0.0);
}
} But your example shows that repeated pdfs in different RooSimultaneous components should better be supported to not cause confusion like this. And in any other case, there should be a strong warning or thrown exception if that happens. |
Could you expand a bit on what exactly the limitation is? I'd like to understand whether my actual model is affected or not. |
The limitation right now is: RooAbsArgs that are in different channels of the RooSimultaneous and depend on data are not allowed to have the same name (by the RooAbsArgs I don't only mean the top-level channel pdf but also anything that is serving that pdf). In your initial example, there was a Gaussian "g" in each channel. But I hope to eliminate this limitation by the next patch release. |
Oh, ok, it's linked to the RooSimultaneous. That makes sense, thank you. |
Yes exactly! |
The new BatchMode always had some trouble in simultaneous fits when the same argument was reused in different components, because intermediate values are stored by argument name and there are different results for each component. To solve this problem, the names of all arguments in a given component are now prefixed by the category label surrounded by underscores. Furthermore, the `getParameters` function for objects created with the new BatchMode is improved such that observables renamed with this prefixing are not confused with parameters. Closes root-project#10991.
The new BatchMode always had some trouble in simultaneous fits when the same argument was reused in different components, because intermediate values are stored by argument name and there are different results for each component. To solve this problem, the names of all arguments in a given component are now prefixed by the category label surrounded by underscores. Furthermore, the `getParameters` function for objects created with the new BatchMode is improved such that observables renamed with this prefixing are not confused with parameters. Closes root-project#10991.
Hi! This problem is now fixed in The fix will make it to the next patch release, as tracked in this issue: |
The new BatchMode always had some trouble in simultaneous fits when the same argument was reused in different components, because intermediate values are stored by argument name and there are different results for each component. To solve this problem, the names of all arguments in a given component are now prefixed by the category label surrounded by underscores. Furthermore, the `getParameters` function for objects created with the new BatchMode is improved such that observables renamed with this prefixing are not confused with parameters. Closes #10991.
The new BatchMode always had some trouble in simultaneous fits when the same argument was reused in different components, because intermediate values are stored by argument name and there are different results for each component. To solve this problem, the names of all arguments in a given component are now prefixed by the category label surrounded by underscores. Furthermore, the `getParameters` function for objects created with the new BatchMode is improved such that observables renamed with this prefixing are not confused with parameters. Closes root-project#10991.
Describe the bug
When fitting a RooSimultaneous pdf using BatchMode(true) (which should be cpu) the fit contains additional parameters, one for each observable, called
_<first category label>_<obs name>
, where the category is the one used in the RooSimultaneous.The fit converges, but fails at the HESSE step, leading to an "approximation only" covariance matrix.
The label used is, from what I understood, based on label ordering and not the indices.
The mapping from category label to index however influences the fit result.
Expected behavior
No extra parameters, successful HESSE
To Reproduce
Setup
Centos7
ROOT 6.26.04 from LCG dev4
Additional context
The text was updated successfully, but these errors were encountered: