More on fits

Fit the function sin

4 APPLICATION SIGMA 4 alpha=array(100,0#2*PI) 4 sina=sin(alpha)+rndm(alpha)*0.1 4 err=array(100,0.1#0.1) 4 EXIT zone 2 2 1 V/FIT ALPHA(1:50) SINA(1:50) ERR(1:50) G 1 V/FIT ALPHA SINA ERR P3 1 V/FIT ALPHA SINA ERR P5 v/create par(1) r 10. 2 V/FIT ALPHA SINA ERR SINFIT.F ! 1 PAR 3 V/PRI PAR

  1. In this macro two different types of predefined fits are used: Gaussian, Polynomial. As we will see later, the histograms fitting command HISTO/FIT has exactly the same syntax except that the 3 vectors are replaced by an unique parameter: the histogram identifier. On histograms some other minimization mechanisms are available via the commands SPLINE , SMOOTH , etc.. .
  2. It is also possible to defined specific functions. Here the function SINFIT is defined as follow:

    The function SINFIT

    function sinfit(x) common /pawpar/ par(1) sinfit=par(1)*sin(x) end
  3. This VECT/PRI shows that now PAR(1) is close to 1.
                                                                                                                       
          PAR(1) = 0.994221                                                                                                 
    
  4. Vector initialization with SIGMA. We will see other SIGMA examples later.
  5. Try to modify the macro and the COMIS program sinfit.f to have a fit with two parameters in order to improve the quality of the fit.


Output of the Gaussian fit

********************************************** * * * Function minimization by SUBROUTINE HFITV * * Variable-metric method * * ID = 0 CHOPT = * * * ********************************************** Convergence when estimated distance to minimum (EDM) .LT. .10E-03 FCN= 2221.676 FROM MIGRAD STATUS=CONVERGED 239 CALLS 240 TOTAL EDM= .85E-05 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 P1 1.1316 .24808E-01 .64412E-03 .15289 2 P2 1.5419 .21417E-01 .62018E-03 .42301E-01 3 P3 -.76813 .17032E-01 .43531E-03 -.25527

Output of the Polynomial fit (P3)

CHISQUARE = .2290E+02 NPFIT = 100 ********************************************** * * * Function minimization by SUBROUTINE HFITV * * Variable-metric method * * ID = 0 CHOPT = * * * ********************************************** Convergence when estimated distance to minimum (EDM) .LT. .10E-03 FCN= 49.31862 FROM MIGRAD STATUS=FAILED 90 CALLS 91 TOTAL EDM= .79E-01 STRATEGY=1 ERROR MATRIX UNCERTAINTY= 70.2% EXT PARAMETER APPROXIMATE STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 P1 -.13523 .34965E-02 .00000E+00 5.6896 2 P2 1.8729 .53793E-02 .00000E+00 -6.8643 3 P3 -.86391 .32623E-03 .00000E+00 94.054 4 P4 .91424E-01 .23105E-03 .00000E+00 6.6564 CHISQUARE = .5137E+00 NPFIT = 100

Output of the Polynomial fit (P5)

********************************************** * * * Function minimization by SUBROUTINE HFITV * * Variable-metric method * * ID = 0 CHOPT = * * * ********************************************** Convergence when estimated distance to minimum (EDM) .LT. .10E-03 FCN= 7.164283 FROM MIGRAD STATUS=FAILED 240 CALLS 241 TOTAL EDM= .19E+01 STRATEGY= 1 ERR MATRIX NOT POS-DEF EXT PARAMETER APPROXIMATE STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 P1 .46785E-01 .20704E-03 .68172E-07 32.993 2 P2 .93224 .10038E-02 .74579E-06 -551.05 3 P3 .20962 .33827E-03 .16770E-06 -3073.1 4 P4 -.36899 .32674E-03 .29519E-06 -1084.4 5 P5 .82836E-01 .19712E-04 .66269E-07 821.80 6 P6 -.52834E-02 .12561E-05 .42267E-08 -5204.8 CHISQUARE = .7622E-01 NPFIT = 100

Output of the ``COMIS'' fit

********************************************** * * * Function minimization by SUBROUTINE HFITV * * Variable-metric method * * ID = 0 CHOPT = * * * ********************************************** Convergence when estimated distance to minimum (EDM) .LT. .10E-03 FCN= 32.13273 FROM MIGRAD STATUS=CONVERGED 21 CALLS 22 TOTAL EDM= .92E-05 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 P1 .99811 .13752E-01 .51510E-04 -.31172 CHISQUARE = .3246E+00 NPFIT = 100


Last update: 96/05/24 17.18
Olivier.Couet@Cern.Ch