Basic concepts of MINUIT

The MINUIT package acts on a multiparameter Fortran function to which one must give the generic name FCN. In the PAW/ HBOOK implementation, the function FCN is called HFCNH when the command Histo/Fit ( PAW) or the routine HFITH are invoked. It is called HFCNV when the command Vector/Fit or the routine HFITV are invoked. The value of FCN will in general depend on one or more variable parameters.

To take a simple example, suppose the problem is to fit a polynomial through a set of data points with the command Vector/Fit. Routine HFCNV called by HFITV calculates the chisquare between a polynomial and the data; the variable parameters of HFCNV would be the coefficients of the polynomials. Routine HFCNV with respect to the parameters, that is, find those values of the coefficients which give the lowest value of chisquare.

Basic concepts - The transformation for parameters with limits.

For variable parameters with limits, MINUIT uses the following transformation:

  P   = arcsin(2((P   -a)/(b- a))-1)                P    = a+((b- a)/(2))(sinP    +1)
   int             ext                               ext                      int

so that the internal value P can take on any value, while the external int value P can take on values only between the lower limit a and the ext upper limit b. Since the transformation is necessarily non-linear, it would transform a nice linear problem into a nasty non-linear one, which is the reason why limits should be avoided if not necessary. In addition, the transformation does require some computer time, so it slows down the computation a little bit, and more importantly, it introduces additional numerical inaccuracy into the problem in addition to what is introduced in the numerical calculation of the FCN value. The effects of non-linearity and numerical roundoff both become more important as the external value gets closer to one of the limits (expressed as the distance to nearest limit divided by distance between limits). The user must therefore be aware of the fact that, for example, if he puts limits of 10 (0,10 ) on a parameter, then the values 0.0 and 1. 0 will be indistinguishable to the accuracy of most machines.

The transformation also affects the parameter error matrix, of course, so MINUIT does a transformation of the error matrix (and the ``parabolic'' parameter errors) when there are parameter limits. Users should however realize that the transformation is only a linear approximation, and that it cannot give a meaningful result if one or more parameters is very close to a limit, where partial P /partial P #0. Therefore, it is ext int recommended that:

  1. Limits on variable parameters should be used only when needed in order to prevent the parameter from taking on unphysical values.
  2. When a satisfactory minimum has been found using limits, the limits should then be removed if possible, in order to perform or re-perform the error analysis without limits.

    How to get the right answer from MINUIT.

    MINUIT offers the user a choice of several minimization algorithms. The MIGRAD (Other algorithms are available with Interactive MINUIT, as described on Page [more info]) algorithm is in general the best minimizer for nearly all functions. It is a variable-metric method with inexact line search, a stable metric updating scheme, and checks for positive-definiteness. Its main weakness is that it depends heavily on knowledge of the first derivatives, and fails miserably if they are very inaccurate. If first derivatives are a problem, they can be calculated analytically inside the user function and communicated to PAW via the routine HDERIV.

    If parameter limits are needed, in spite of the side effects, then the user should be aware of the following techniques to alleviate problems caused by limits:

    Getting the right minimum with limits.

    If MIGRAD converges normally to a point where no parameter is near one of its limits, then the existence of limits has probably not prevented MINUIT from finding the right minimum. On the other hand, if one or more parameters is near its limit at the minimum, this may be because the true minimum is indeed at a limit, or it may be because the minimizer has become ``blocked'' at a limit. This may normally happen only if the parameter is so close to a limit (internal value at an odd multiple of #((pi)/(2)) that MINUIT prints a warning to this effect when it prints the parameter values. The minimizer can become blocked at a limit, because at a limit the derivative seen by the minimizer partial F/partial P is zero no matter int what the real derivative partial F/partial P is. ext

    ((partial F)/(partial P ))= ((partial F)/(partial P ))((partial P )/(partial P )) =((partial F)/(partial P ))= 0 int ext ext int ext

    Getting the right parameter errors with limits.

    In the best case, where the minimum is far from any limits, MINUIT will correctly transform the error matrix, and the parameter errors it reports should be accurate and very close to those you would have got without limits. In other cases (which should be more common, since otherwise you wouldn't need limits), the very meaning of parameter errors becomes problematic. Mathematically, since the limit is an absolute constraint on the parameter, a parameter at its limit has no error, at least in one direction. The error matrix, which can assign only symmetric errors, then becomes essentially meaningless.

    Interpretation of Parameter Errors:

    There are two kinds of problems that can arise: the reliability of MINUIT's error estimates, and their statistical interpretation, assuming they are accurate.

    Statistical interpretation:

    For discussuion of basic concepts, such as the meaning of the elements of the error matrix, or setting of exact confidence levels (see [bib-EADIE]).

    Reliability of MINUIT error estimates.

    MINUIT always carries around its own current estimates of the parameter errors, which it will print out on request, no matter how accurate they are at any given point in the execution. For example, at initialization, these estimates are just the starting step sizes as specified by the user. After a HESSE step, the errors are usually quite accurate, unless there has been a problem. MINUIT, when it prints out error values, also gives some indication of how reliable it thinks they are. For example, those marked CURRENT GUESS ERROR are only working values not to be believed, and APPROXIMATE ERROR means that they have been calculated but there is reason to believe that they may not be accurate.

    If no mitigating adjective is given, then at least MINUIT believes the errors are accurate, although there is always a small chance that MINUIT has been fooled. Some visible signs that MINUIT may have been fooled are:

    1. Warning messages produced during the minimization or error analysis.
    2. Failure to find new minimum.
    3. Value of EDM too big (estimated Distance to Minimum).
    4. Correlation coefficients exactly equal to zero, unless some parameters are known to be uncorrelated with the others.
    5. Correlation coefficients very close to one (greater than 0.99). This indicates both an exceptionally difficult problem, and one which has been badly parameterized so that individual errors are not very meaningful because they are so highly correlated.
    6. Parameter at limit. This condition, signalled by a MINUIT warning message, may make both the function minimum and parameter errors unreliable. See the discussion above ``Getting the right parameter errors with limits''.

      The best way to be absolutely sure of the errors, is to use ``independent'' calculations and compare them, or compare the calculated errors with a picture of the function. Theoretically, the covariance matrix for a ``physical'' function must be positive-definite at the minimum, although it may not be so for all points far away from the minimum, even for a well-determined physical problem. Therefore, if MIGRAD reports that it has found a non-positive-definite covariance matrix, this may be a sign of one or more of the following:

      A non-physical region:

      On its way to the minimum, MIGRAD may have traversed a region which has unphysical behaviour, which is of course not a serious problem as long as it recovers and leaves such a region.

      An underdetermined problem:

      If the matrix is not positive-definite even at the minimum, this may mean that the solution is not well-defined, for example that there are more unknowns than there are data points, or that the parameterization of the fit contains a linear dependence. If this is the case, then MINUIT (or any other program) cannot solve your problem uniquely, and the error matrix will necessarily be largely meaningless, so the user must remove the underdeterminedness by reformulating the parameterization. MINUIT cannot do this itself.

      Numerical inaccuracies:

      It is possible that the apparent lack of positive-definiteness is in fact only due to excessive roundoff errors in numerical calculations in the user function or not enough precision. This is unlikely in general, but becomes more likely if the number of free parameters is very large, or if the parameters are badly scaled (not all of the same order of magnitude), and correlations are also large. In any case, whether the non-positive-definiteness is real or only numerical is largely irrelevant, since in both cases the error matrix will be unreliable and the minimum suspicious.

      An ill-posed problem:

      For questions of parameter dependence, see the discussion above on positive-definiteness.

      Possible other mathematical problems are the following:

      Excessive numerical roundoff:

      Be especially careful of exponential and factorial functions which get big very quickly and lose accuracy.

      Starting too far from the solution:

      The function may have unphysical local minima, especially at infinity in some variables.

      MINUIT interactive mode

      [H2MWMIN]

      With the routines HFITH or HFITV and the M option, HBOOK goes into interactive mode and gives control to the MINUIT program. In this case, the user may enter MINUIT control statements directly.

      Overview of available MINUIT commands

      CLEar

      Resets all parameter names and values to undefined. Must normally be followed by a PARAMETER command or equivalent, in order to define parameter values.

      CONtour par1 par2 [devs][ngrid]

      Instructs MINUIT to trace contour lines of the user function with respect to the two parameters whose external numbers are par1 and par2. Other variable parameters of the function, if any, will have their values fixed at the current values during the contour tracing. The optional parameter [devs] (default value 2.) gives the number of standard deviations in each parameter which should lie entirely within the plotting area. Optional parameter [ngrid] (default value 25 unless page size is too small) determines the resolution of the plot, i.e. the number of rows and columns of the grid at which the function will be evaluated.

      EXIT

      End of Interactive MINUIT. Control is returned to PAW.

      FIX parno

      Causes parameter parno to be removed from the list of variable parameters, and its value will remain constant (at the current value) during subsequent minimizations, etc., until another command changes its value or its status.

      HELP [SET][SHOw]

      Causes MINUIT to list the available commands. The list of SET and SHOw commands must be requested separately.

      HESse [maxcalls]

      Instructs MINUIT to calculate, by finite differences, the Hessian or error matrix. That is, it calculates the full matrix of second derivatives of the function with respect to the currently variable parameters, and inverts it, printing out the resulting error matrix. The optional argument [maxcalls] specifies the (approximate) maximum number of function calls after which the calculation will be stopped.

      IMProve [maxcalls]

      If a previous minimization has converged, and the current values of the parameters therefore correspond to a local minimum of the function, this command requests a search for additional distinct local minima. The optional argument [maxcalls] specifies the (approximate) maximum number of function calls after which the calculation will be stopped.

      MIGrad [maxcalls][tolerance]

      Causes minimization of the function by the method of Migrad, the most efficient and complete single method, recommended for general functions (see also MINImize). The minimization produces as a by-product the error matrix of the parameters, which is usually reliable unless warning messages are produced. The optional argument [maxcalls] specifies the (approximate) maximum number of function calls after which the calculation will be stopped even if it has not yet converged. The optional argument [tolerance] specifies required tolerance on the function value at the minimum. The default tolerance is 0.1. Minimization will stop when the estimated vertical distance to the minimum ( EDM) is less than 0.001*[tolerance]*UP (see SET ERR).

      MINImize [maxcalls][tolerance]

      Causes minimization of the function by the method of Migrad, as does the MIGrad command, but switches to the SIMplex method if Migrad fails to converge. Arguments are as for MIGrad.

      MINOs [maxcalls][parno][parno]...

      Causes a Minos error analysis to be performed on the parameters whose numbers [parno] are specified. If none are specified, Minos errors are calculated for all variable parameters. Minos errors may be expensive to calculate, but are very reliable since they take account of non-linearities in the problem as well as parameter correlations, and are in general asymmetric. The optional argument [maxcalls] specifies the (approximate) maximum number of function calls per parameter requested, after which the calculation will be stopped for that parameter.

      RELease parno

      If parno is the number of a previously variable parameter which has been fixed by a command: FIX parno, then that parameter will return to variable status. Otherwise a warning message is printed and the command is ignored. Note that this command operates only on parameters which were at one time variable and have been FIXed. It cannot make constant parameters variable; that must be done by redefining the parameter with a PARAMETER command.

      REStore [code]

      If no [code] is specified, this command restores all previously FIXed parameters to variable status. If [code]=1, then only the last parameter FIXed is restored to variable status.

      SCAn [parno][numpts][from][to]

      Scans the value of the user function by varying parameter number [parno], leaving all other parameters fixed at the current value. If [parno] is not specified, all variable parameters are scanned in sequence. The number of points [numpts] in the scan is 40 by default, and cannot exceed 100. The range of the scan is by default 2 standard deviations on each side of the current best value, but can be specified as from [from] to [to]. After each scan, if a new minimum is found, the best parameter values are retained as start values for future scans or minimizations. The curve resulting from each scan is plotted on the output unit in order to show the approximate behaviour of the function. This command is not intended for minimization, but is sometimes useful for debugging the user function or finding a reasonable starting point.

      SEEk [maxcalls][devs]

      Causes a Monte Carlo minimization of the function, by choosing random values of the variable parameters, chosen uniformly over a hypercube centered at the current best value. The region size is by default 3 standard deviations on each side, but can be changed by specifying the value of [devs].

      SET ERRordef up

      Sets the value of up (default value= 1.), defining parameter errors. MINUIT defines parameter errors as the change in parameter value required to change the function value by up. Normally, for chisquared fits up=1, and for negative log likelihood, up=0.5.

      SET LIMits [parno][lolim][uplim]

      Allows the user to change the limits on one or all parameters. If no arguments are specified, all limits are removed from all parameters. If [parno] alone is specified, limits are removed from parameter [parno]. If all arguments are specified, then parameter [parno] will be bounded between [lolim] and [uplim]. Limits can be specified in either order, MINUIT will take the smaller as [lolim] and the larger as [uplim]. However, if [lolim] is equal to [uplim], an error condition results.

      SET PARameter parno value

      Sets the value of parameter parno to value. The parameter in question may be variable, fixed, or constant, but must be defined.

      SET PRIntout level

      Sets the print level, determining how much output MINUIT will produce. The allowed values and their meanings are displayed after a SHOw PRInt command. Possible values for level are:

      -1
      No output except from SHOW commands
      0
      Minimum output (no starting values or intermediate results)
      1
      Default value, normal output
      2
      Additional output giving intermediate results.
      3
      Maximum output, showing progress of minimizations.

      SET STRategy level

      Sets the strategy to be used in calculating first and second derivatives and in certain minimization methods. In general, low values of level mean fewer function calls and high values mean more reliable minimization. Currently allowed values are 0, 1 (default), and 2.

      SHOw XXXX

      All SET XXXX commands have a corresponding SHOw XXXX command. In addition, the SHOw commands listed starting here have no corresponding SET command for obvious reasons. The full list of SHOw commands is printed in response to the command HELP SHOw.

      SHOw CORrelations

      Calculates and prints the parameter correlations from the error matrix.

      SHOw COVariance

      Prints the (external) covariance (error) matrix.

      SIMplex [maxcalls][tolerance]

      Performs a function minimization using the simplex method of Nelder and Mead. Minimization terminates either when the function has been called (approximately) [maxcalls] times, or when the estimated vertical distance to minimum ( EDM) is less than [tolerance]. The default value of [tolerance] is 0.1*UP (see SET ERR).