# Setting Value of Fit Parameter to Depend on Another Fit Parameter Value

**URL:** <https://root-forum.cern.ch/t/setting-value-of-fit-parameter-to-depend-on-another-fit-parameter-value/55819>\
**Category:** Newbie\
**Tags:** roofit, root\
**Created:** [July 24, 2023, 10:02pm UTC](https://root-forum.cern.ch/t/setting-value-of-fit-parameter-to-depend-on-another-fit-parameter-value/55819 "2023-07-24T22:02:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bassam](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@Bassam](https://root-forum.cern.ch/u/Bassam)\
**Post date:** [July 24, 2023, 10:02pm UTC](https://root-forum.cern.ch/t/setting-value-of-fit-parameter-to-depend-on-another-fit-parameter-value/55819/1 "2023-07-24T22:02:36Z")

</div>

Hello all,

I would like to perform a fit, where the value of one of the fit parameters depends on the value of another fit parameter. For example, lets say I have a functions that has two parameters, then what I would like to do is the following:

```auto
Int_t fixedValue = 2;
fitFunction->SetParameter(0, 1.);
fitFunction->FixParameter(1, fitFunction->GetParamter(0) + fixedValue);

```

Basically, if I know the value of `par[0]`, then `par[1] = par[0] + fixedValue`. However, this is a much more simplified version of my actual situation, so I do not want to define `par[1] = par[0] + fixedValue` in my user defined function, and I was wondering if I could obtain the same results by using the above block of code? Or, is there a better method to achieve what I want?

Thank you very much and any help is appreciated!

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [July 25, 2023, 12:29pm UTC](https://root-forum.cern.ch/t/setting-value-of-fit-parameter-to-depend-on-another-fit-parameter-value/55819/2 "2023-07-25T12:29:51Z")

</div>

Hi @Bassam!

No, it does not work like this unfortunately. If you do `fitFunction->FixParameter(1, fitFunction->GetParamter(0) + ...)` it will take the value that the zeroth parameter currently has, it’s not that there two parameters are now connected.

Is what you’re doing a likelihood fit? If you want to do more complicated likelihood fits, then you should consider using [RooFit](https://root.cern/manual/roofit/). Is that an option for you?

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![Bassam](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@Bassam](https://root-forum.cern.ch/u/Bassam)\
**Post date:** [July 27, 2023, 9:05pm UTC](https://root-forum.cern.ch/t/setting-value-of-fit-parameter-to-depend-on-another-fit-parameter-value/55819/3 "2023-07-27T21:05:33Z")

</div>

Thank you very much for your reply @Jonas! I will look into it and also try different ideas. Worst case scenario, I will resort to replacing `par[1]` with `par[0] + fixedValue` in the function definition.
