TF1::GetParLimits after FixParameter and ReleaseParameter

Hi,

how is it possible to distinguish whether a parameter of a TF1 is fixed to 0 or it doesn’t have limits on that parameter at all? Both methods TF1::FixParameter(i,0) and TF1::ReleaseParameter(i) lead to lmin == lmax == 0.0 when calling TF1::GetParLimits(i, lmin, lmax). I wasn’t able to find another method in the interface of TF1 about par limits.

In HFitImpl.cxx line 264 I found a comment saying // this is a limitation - cannot fix a parameter to zero value. Is this the case?

I also noticed that parameter limits on automatic functions like gaus(0) seem to be ignored. This example

TH1F h1("h1","",100,-5,5);
h1.FillRandom("gaus",10000);
TF1 f1("f1","gaus(0)",-5,5);
f1.FixParameter(1,0.1); 
h1.Fit("f1");

gives the output

  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  Constant     4.00101e+02   4.88023e+00   1.58450e-02   4.82959e-05
   2  Mean        -1.20600e-02     fixed    
   3  Sigma        9.91531e-01   6.94493e-03   7.54781e-06   1.08163e-01

which is sort of funny, since ROOT still reports that parameter 1 (Mean) is fixed. Using a non-automatic function instead

TF1 f1("f1","[0]*TMath::Gaus(x,[1],[2]),-5,5); 
f1.SetParameters(1,0,1);
f1.FixParameter(1,0);

obeys the fixed parameter setting

   1  p0           3.99512e+02   4.89352e+00   1.48596e-02  -1.17658e-04
   2  p1           0.00000e+00     fixed    
   3  p2           9.93449e-01   7.02990e-03   2.13445e-05  -9.73509e-02

I’m confused now.

Best regards and thanks,
Klaus


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22/06
Platform: Not Provided
Compiler: Not Provided


Maybe @moneta knows if it’s possible to distinguish

Hi,
When a parameter is fixed, their limits (stored in the TF1 class) are set to the parameter value.
For the case where the parameter value = 0, then the limits are set to value =1. See ROOT: hist/hist/src/TF1.cxx Source File

So, to see if a parameter is fixed you just need to do the same check as in HFitImpl.cxx line 263 that
will work also for the zero case:

bool IsParameterFixed (TF1 & f1, int ipar) {
  double pmin,pmax;
  f1.GetParLimits(ipar,pmin,pmax); 
  return (pmin*pmax !=0 && pmin >= pmax);
}

Concerning your other question, to use limits on pre-defined functions you need to use the fit option "B". You need however to set in this case the initial function parameters, otherwise the fit will not converge.

Best Regards

Lorenzo

1 Like

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