Minuit Hints


[Peter Minuit]. 1580-1638. Dutch colonial administrator who bought Manhattan from the Native Americans for the equivalent of $24.

[minuit]. midnight (French).


Minuit is the most common minimization software in use in high energy physics, especially for cases with many variable parameters. It was therefore deemed beneficial by the CDF Statistics Committee to provide some guidance to users who will be employing Minuit in their analyses. We present a set of specific suggestions to help the user avoid pitfalls and succeed in obtaining the correct answer, focusing on unbinned maximum likelihood fits:

  1. Read the manual: The Minuit reference manual (F. James, "Minuit, Function Minimization and Error Analysis", CERN long writeup D506) is packed with useful advice. In addition to the obligatory technicalities, there are chapters entitled "Minuit Basic Concepts", "How to get the right answer from Minuit", and "Interpretation of the errors on Minuit parameters" that deserve careful study. If you haven't read it recently, read it again. There is little below that can't be found in the Minuit reference manual.
  2. Provide initial values reasonably close to the true minimum: Doing some preliminary computation to make initial estimates of the parameters can save a lot of time and trouble. Of course, this computation should be automated---computed in the code before the calls that provide Minuit with the starting values. Sometimes this can be as simple as computing the sample mean or median, but may involve more work, as, for example, binning the data to find the mode.
  3. Keeping Minuit out of undefined regions: In some cases, Minuit may have a tendency to wander into regions where the function to be minimized (FCN) is not defined (e.g. yielding the logarithm of a negative number). Parameter limits may help in simple cases. In cases with non-rectangular boundaries, one can test for the illegal excursions within FCN before they cause serious problems (i.e. division by zero, floating point exceptions, ...), print out a message (or otherwise signal the user), and return a valid but very large floating point number to Minuit. The presence of such messages should lead the user to be suspicious about Minuit's error-estimates, and the big return value should keep Minuit from going too far off course. Hopefully, after the desired minimum is located, if the fit is restarted at that point, Minuit will not stray again into the undefined region.
  4. One sided limits: It is common that one needs to restrict a particular parameter only on one side---for example, to be non-negative. If the user decides to set limits, in this case there is a temptation to set the upper limit to some very large number. This is sure to cause major problems (see the manual). It would be better to set the limits so that the location of the minimum is roughly midway between the lower and upper limit. But limits should only be used when they are really needed---if Minuit does not drift into the parameter's illegal region, no limit is needed for that parameter.
  5. Minuit strategy level: The default strategy level is 1. If you need reliable error estimates, set the strategy to 2. One normally needs reliable error estimates from the final fit.
  6. Numerical precision: Maintain full double precision for the calculations done in FCN. If you must depend on someone else's code, and it has lower precision, use the "SET EPS" command appropriately, and hope for the best.
  7. Difficult cases: In cases where Minuit just can't locate the minimum, some preliminary fits, in which some subset of the parameters are fixed, may help. After several such fits (each fixing a different subset), Minuit is (one hopes) close enough to the true minimum so that all parameters can be freed. Naturally, this requires some experimentation.
  8. User provided derivatives: In a case with a large number of variable parameters, Minuit may benefit from being provided analytic derivatives by FCN. As it is easy to make mistakes when coding these derivatives, Minuit does a spot check for accuracy before it agrees to accept them (see the SET GRADIENT command).
  9. Error matrix status messages: When it is important to get accurate error estimates, the user should only accept errors associated with the "ERROR MATRIX ACCURATE" message. A message like "ERROR MATRIX UNCERTAINTY=4.5%" generally means the errors are not to be trusted.
  10. Convergence status messages: If you don't get STATUS=CONVERGED at the end, you may not be anywhere near a minimum. The reason for termination before convergence may be as simple as hitting the limit on the number of calls, but, in any case, you can't assume that Minuit has located a minimum without the proper status.

A Minuit Example

We provide a simple working example for the beginner that illustrates some of these concepts. The code is written in Clean C, the common subset of ISO C and C++, and can be compiled either as a C program or a C++ program. It must be linked to the CERN library packlib, and also illustrates how to call Fortran routines from C and C++ in a Unix environment. Further instructions are included as comments in the code.

The function that this example minimizes is

f(x,y) = sin²(pi*x) + sin²(pi*y) + (x-sqrt(2)*y
which has a unique global minimum at (0,0), and many local minima. The user has the opportunity to discover how Minuit behaves given various starting values.
Joel Heinrich
Last modified: September 24, 2002