FIT

fit_parameters

 A maximum of 25 fitting parameters are allowed in the expression.
 Variable fitting parameters are created with the SCALAR\VARY command, and
 can be converted to fixed value scalar variables with the SCALAR command.
 By default, variable fitting parameters are left at their last calculated
 values when fitting stops due to an unsuccessful fit or a control-c abort.
 Use the \RESET qualifier to cause the fitting parameters to be reset to
 their original values after an unsuccessful fit or a control-c abort.
 If the \VARNAMES qualifier is used, an array text variable named FIT$VAR
 will be made which will contain the names of the fitting parameter
 variables.  The array length of FIT$VAR will be equal to the number of
 fit parameters.

normal_fit

 Assume that each data point has an error that is independently random
 and distributed as a normal distribution. The weighted chi-square function,
 as a function of the fit parameters, is minimized using a Gauss-Newton
 method. Serious difficulties can arise when the expression is sufficiently
 nonlinear and chi-square is large at the minimum.  If not entered, the
 weights, defined as the reciprocals of the variances, default to 1.0 for
 each data point. 

Additional Information on:

  • weights
  • zeros
  • Poisson_fit

     Assume that each data point has an error that is independently random
     and distributed as a Poisson distribution. The log likelihood function,
     as a function of the fit parameters, is minimized using a Gauss-Newton
     method. Since logarithms are involved, a good first approximation is 
     required before starting the Poisson fit.  Try a normal fit first, and
     use these derived parameter values to start off the Poisson fit.
     Weights do not have meaning, and so are not used, in a Poisson fit. 
    

    accuracy

     Indications of the accuracy of the fit are displayed in the output under
     the names E1 and E2. E1[i] is the root mean square statistical error of
     estimate, and the root mean square total error of estimate, or standard
     error, is displayed under E2.
    
     The w[k] for k=1,...,N are the weights which the user can specify for
     each data point. The accuracy of the parameters in a linear fit is
     p[i]+/-E2[i] for i=1,...,M.  In theory, for the standard error E2 to
     be correct, the weights w[k] must be proportional to the variance of
     the probability distribution of y[k]. 
    

    chi-square

     If the \CHISQ qualifier is used, a scalar named FIT$CHISQ will be made
     with value equal to chi-square.
    

    confidence_level

     If the \CL qualifier is used, a scalar named FIT$CL will be made with
     value equal to the confidence level, which is the probability that a 
     random repeat of the given experiment would observe a worse chi-square,
     assuming the correctness of the model.
    

    errors

     If the \E1 qualifier is used, then the root mean square statistical
     errors for each fit parameter are output into an automatically created
     vector named FIT$E1. The length of FIT$E1 will be equal to the number of
     fit parameters.
    
     If the \E2 qualifier is used, then the root mean square total error of
     estimate for each parameter are output into an automatically created
     vector named FIT$E2. The length of FIT$E2 will be equal to the number of
     fit parameters.
    

    correlations

     A matrix with the name FIT$CORR will be created if the \CORRMAT qualifier
     is used. This matrix will contain the correlation matrix for the fit.
     A matrix with the name FIT$COVM will be created if the \COVMAT qualifier
     is used. This matrix will contain the covariance matrix for the fit.
     The size of these matrices will be N by N, where N is the number of
     parameters in the fit.  The E1's are the square roots of the diagonal
     elements of the covariance matrix.
    

    iteration_steps

     Syntax: FIT\ITMAX n y=expression
             FIT\WEIGHTS\ITMAX w n y=expression
             FIT\WEIGHTS\ITMAX\TOLERANCE w n eps y=expression
             FIT\ITMAX\TOLERANCE n eps y=expression
    
     The \ITMAX qualifier allows the user to specify the maximum number of
     iteration steps for the fit. When this maximum number is reached, the
     fit will stop, and the variable parameters will be updated to their last
     values. The fit will also stop if the fit is successful before this maximum
     iteration number is reached.  If the \WEIGHT qualifier is also used, the
     weight array comes before the iteration number in the parameter list.
    

    tolerance

     Syntax: FIT\TOLERANCE eps y=expression
             FIT\WEIGHTS\TOLERANCE w eps y=expression
             FIT\ITMAX\TOLERANCE n eps y=expression
             FIT\WEIGHTS\ITMAX\TOLERANCE w n eps y=expression
    
     The \TOLERANCE qualifier allows the user to specify the fitting tolerance
     (default value 0.00001). This value is used in calculating the central
     difference formula for the partial derivatives, that is, the partial
     derivative of f(x,p) wrt p  is approximated by
      f(x,p*(1+eps))-f(x,p*(1-eps))/(2*eps*p)
     This value is also used to determine when the fit is successful.
     The parameter order is:  weights, itmax, tolerance.
    

    degrees_of_freedom

     If the \FREE qualifier is used, then the number of degrees of freedom
     for the fit is output into an automatically created scalar named FIT$FREE.
     The number of degrees of freedom is either the number of data values minus
     the number of parameters, or, if the \-ZEROS qualifier is also used, the
     number of non-zero weights minus the number of parameters.
    

    MESSAGES

     If the \NOMESSAGES qualifier is used, then there will be no informational
     messages output to the monitor screen.
    

    UPDATE

     Syntax: FIT\UPDATE yout
    
     The FIT\UPDATE command evaluates the previously fitted expression, that
     is, the expression to the right of the = in the last FIT command, for
     the current parameter values and stores this result in the vector yout.
    
     This is exactly equivalent to entering: yout=previously_fitted_expression
     and is provided to obviate the necessity of re-entering a complicated
     expression. Note that the vector yout usually differs from the name of
     the vector being fitted to avoid destroying the original data.
    

    example

     To fit a straight line to some data stored in vectors X and Y, use:
    
     SET PCHAR -1       ! use unconnected box plotting symbols
     GRAPH X Y          ! plot the original data
     SCALAR\VARY A B    ! create 2 variable fitting parameters
     FIT Y=A*X+B        ! fit to the line
     FIT\UPDATE YF      ! create vector YF 
     SET PCHAR 0        ! turn off plotting symbol
     GRAPH\NOAXES X YF  ! overlay the fitted line