# RooFit: fit with constrain

Hello,

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:

Many thanks
Georgia

Hi Giorgia,

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:

1. 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

2. 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>) ;
RooMinuit m(nllp) ;