How to use TF1::SetParLimits on a function of two parameters?

Dear Experts,

I want to fit a 1D histogram using a one-dimensional generalized Gaussian function. This generalized Gaussian function has three parameters (excluding the normalization constant). I explained this below in detail.


Double_t generalised_1Dgauss(double *x, double *par)
{
return (par[0]/(2.*par[1]*tgamma(1./par[0])))*TMath::Exp(-pow((abs(x[0]-par[2])/par[1]),par[0]));
}

Double_t SigmaWidth_generalised_1Dgauss(TF1* f1)
{
return std::sqrt((pow(f1->GetParameter(1),2)*tgamma(3/f1->GetParameter(0)))/tgamma(1/f1->GetParameter(0)));
}


TH1D * hist_1D; (Already filled with the data points)
double xmin = -4.0;
double xmax = 4.0;

TF1* GenGauss = new TF1(“GenGauss”, generalised_1Dgauss, xmin, xmax, 3);

Now Set the parameters:
GenGauss->SetParameters(value0, value1, value2);

Now Set the parameter Limits:
GenGauss->SetParLimits(0, value0_min, value0_max);
GenGauss->SetParLimits(1, value1_min, value1_max);
GenGauss->SetParLimits(2, value2_min, value2_max);

double width_gengauss = SigmaWidth_generalised_1Dgauss(GenGauss);

Here I also want to use SetParLimits on “width_gengauss”, which is a function of par[0] and par[1].

GenGauss->SetParLimits(width_gengauss, width_min, width_max);
[I know it is not the correct procedure, but I need a similar one.]

Now, I would proceed with fitting.

hist_1D->Fit(GenGauss, “SER”);
hist_1D->Fit(GenGauss, “SER”);
hist_1D->Fit(GenGauss, “SER”);


Could you please suggest how I can apply “SetParLimits” on the new parameter “width_gengauss” for the fitting? If you suggest another way to set limits on “width_gengauss,” it will also be fine.

I am looking forward to hearing from you.

Thanks & Regards,
Sayan

Hi @SAYAN_CHATTERJEE; maybe @couet can help here.

Cheers.
J.

The expert in that area in @moneta

Dear @moneta,

Could you please help? It is very important for me!

Thanks & Regards,
Sayan

Hi,
Unfortunately for fitting you can set up only trivial parameter limits, you cannot setup a constraint as a function of parameters. It is something much more complicated and we are working on this.
The only possibility and re-parametrize (if possible) your function such as a new parameter is the one you want to constraint.
If not possible you can try adding a barrier in the minimization function (e.g. chi2) such that the minimization function becomes very large in the not-allowed region

Lorenzo

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