Re: TF1::FixParameter

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 17 Dec 2007 12:50:19 +0100


Hi Thomas,

When fixing a parameter, you should specify the "B" option. However, when standard functions like "gaus", "polN","expo" are used, their initial parameter values are
automatically estimated. In this case, you should slightly modify your script as follows:
{
  TH1* Hist = new TH1I( "Hist", "Hist", 21, -10.5, +10.5 );   Hist->FillRandom( "gaus" );                                       

  TF1* Fit = new TF1( "myfit", "gaus" );   Fit->SetParameters(1,0,1); //===>set initial values for the parameters   Fit->FixParameter( 1, 0 );

  Hist->Fit( Fit,"b" ); //fit with option "B" }

Rene

Thomas Lauf wrote:
> Hello,
>
> I do not quite understand how the function TF1::FixParameter works.
> When I run the following macro,
>
> {
> TH1* Hist = new TH1I( "Hist", "Hist", 21, -10.5, +10.5 );
> Hist->FillRandom( "gaus" );
>
> TF1* Fit = new TF1( "myfit", "gaus" );
> Fit->FixParameter( 1, 0.0 );
>
> Hist->Fit( Fit );
> }
>
> where I fit a random gaussian distribiution with a function whose mean
> I fixed at 0.0, I get e.g. the following result:
>
> FCN=3.83732 FROM MIGRAD STATUS=CONVERGED 41 CALLS 42
> TOTAL
> EDM=1.02145e-10 STRATEGY= 1 ERROR MATRIX
> ACCURATE
> EXT PARAMETER STEP FIRST
> NO. NAME VALUE ERROR SIZE DERIVATIVE
> 1 Constant 2.00922e+03 3.46544e+01 3.05267e-02 -2.58214e-07
> 2 Mean -9.80000e-03 fixed
> 3 Sigma 9.92018e-01 9.78696e-03 2.89142e-06 -5.29594e-03
>
> Ok, the mean is close to 0.0 and declared 'fixed', but why is it not
> exactly 0.0?
>
> Thanks for any clarifications
>
> Thomas
>
>
> --
> Thomas Lauf
> MPE - MPI Halbleiterlabor
> E-Mail: thl_at_hll.mpg.de
>
Received on Mon Dec 17 2007 - 12:48:26 CET

This archive was generated by hypermail 2.2.0 : Mon Dec 17 2007 - 17:50:02 CET