# Fit with constraints in TMinuit

**URL:** <https://root-forum.cern.ch/t/fit-with-constraints-in-tminuit/63824>\
**Category:** ROOT\
**Tags:** root\
**Created:** [June 28, 2025, 8:16am UTC](https://root-forum.cern.ch/t/fit-with-constraints-in-tminuit/63824 "2025-06-28T08:16:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [July 8, 2025, 8:38am UTC](https://root-forum.cern.ch/t/fit-with-constraints-in-tminuit/63824/6 "2025-07-08T08:38:59Z")

</div>

Hi @OrangeCat

you may find a minimal working code here:

> [@ROOT::FIT, parameter error propagation](https://root-forum.cern.ch/t/root-fit-parameter-error-propagation/23778/4):
>
> Hi, Here is an example where the constraint is added for the parameter 1, slope of the exponential Lorenzo[propagateSystematicErrors.C](https://root-forum.cern.ch/uploads/default/original/2X/4/4855b3953a503109d86f5d9d847577319f01f8ce.C) (2.4 KB)

The key is in line 67,

```auto
auto nll = [&](const double *x) { 
        return likelihood_F(x) - std::log( ROOT::Math::normal_pdf(x[1],sigmaPar, meanPar) ); };

```

where `likelihood_F(x) ` is the negative log likelihood estimator, and `std::log( ... )` is the constraint.

I am not a great expert, but I suspect that the result might be biased when adding constraints, so please try at least with some synthetic data (where you know the parameters) similar to your experimental data, to crosscheck that your method is still robust and non-biased (check the pulls)

Best,  
Alvaro

---

_[View the full topic](https://root-forum.cern.ch/t/fit-with-constraints-in-tminuit/63824)._
