# ROOT::Fit: Constraint change of two parameters

**URL:** <https://root-forum.cern.ch/t/root-constraint-change-of-two-parameters/29336>\
**Category:** ROOT\
**Created:** [June 12, 2018, 1:59pm UTC](https://root-forum.cern.ch/t/root-constraint-change-of-two-parameters/29336 "2018-06-12T13:59:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atd](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/atd/32/33835_2.png) [@atd](https://root-forum.cern.ch/u/atd)\
**Post date:** [June 12, 2018, 1:59pm UTC](https://root-forum.cern.ch/t/root-constraint-change-of-two-parameters/29336/1 "2018-06-12T13:59:40Z")

</div>

Dear rooters,

following the idea presented here,  
[how to propagate errors adding a penalty to the minimizer](https://root-forum.cern.ch/t/root-fit-parameter-error-propagation/23778)

I wonder if this similar procedure is correct: if two parameters are free, but they have no physical meaning unless `0 < par[0] + par[1] < 1`, the constraint to be added will be

```auto
//-- Ancillary functions for the constraint
TF1 * f_par = new TF1("f_par", " double( 0 > [0] + [1] || [0] + [1] > 1 )" ) // =1 if params out of range
ROOT::Math::WrappedMultiTF1 wf_par ( * f_par , 1 );
ROOT::Fit::PoissonLLFunction likelihood_F_par(data_h, wf_par );

auto nll = [&](const double *x) { return likelihood_F(x) - likelihood_F_par(x); };

fitter.FitFCN(2,nll,0,data_h.Size(),false);

```

Is this correct?

Thank you for your time.

Best regards,  
Alvaro.

* * *

_ROOT Version:_ 6.10  
_Platform:_ CC7  
_Compiler:_ gcc 4.8

* * *

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 15, 2018, 2:59pm UTC](https://root-forum.cern.ch/t/root-constraint-change-of-two-parameters/29336/2 "2018-06-15T14:59:32Z")

</div>

Hi,

I am not sure what you are doing is fully correct. Adding a Poisson contraints has a meaning of saying that there is an auxilliary measurement. It is equivalent like adding a Gamma constraint to the parameter/  
Here instead you want to constraint the parameters in a specific range, this is different. Maybe a penalty term, which adds very large value to the likelihood outside the range could be used

Lorenzo

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [June 29, 2018, 2:59pm UTC](https://root-forum.cern.ch/t/root-constraint-change-of-two-parameters/29336/3 "2018-06-29T14:59:34Z")

</div>

Closed on June 29, 2018, 2:59pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
