I am trying to fit data with a model PDF to be a composite model as of:
where the coefficiencts f1, f2 and (1-f1-f2) would like to sum up to 1 . My problem is that sometimes the coefficient f3=1-f1-f2 can get negative values which are unphysical in my case.
How can I specify in RooFit the constrain that 1-f1-f2>0 ?
ps: I would like to avoid the change of interpration of the parameters with re-arranging the PDF as:
Rearranging the parameters recursively is the only completely fail-safe way to do this.
However, since you don’t want this you can try two other ideas:
If you roughly know what the values of of f1 and f2 are going to be you could constrain
the range of allowed values of each of them such that they cannot add up to more than one.
The feasibility of this techniques strongly depend on the final values of f1 and f2
You can add a constraint term to the fit that increases the likelihood by a lot of
(1-f1-f2) becomes negative. This may however cause the fit to fail to converge
as MINUIT is not very keen on discontinuities in the likelihood. You can do this e.g. as follows
RooFormulaVar penalty(“penalty”,“100*((1-f1-f2)<0)”,RooArgSet(f1,f2)) ;
which defines a function that is zero when 1-f1-f2>0 and 100 and it is less than zero.
You then do
RooAbsReal* nll = mypdf.createNLL(<same arguments as fitTo here>) ;
RooAddition nllp("nllp","nllp",RooArgSet(*nll,penalty)) ;
RooMinuit m(nllp) ;
Finally, you can also run the fit with recursive fraction, and then extract your results in
the form of absolute fractions by calculating them a posteriori, e.g. you write a RooFormulaVar
for each absolute fraction in terms of recursive fraction parameters.
This will allow you to represent the fit result in absolute parameters. If you save the RooFitResult
of the fit, you can also calculate the errors on the absolute fractions as follows
Double_t err = absFractionFunc.getPropagatedError(myFitResult) ;