# 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/(2.*par*tgamma(1./par)))*TMath::Exp(-pow((abs(x-par)/par),par));
}

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 and par.

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,