Close This Window

For using on the web or on a screen

For printing in high resolution

White version, for dark backgrounds

Institut Laue-Langevin

The Computing for Science (CS) group supports ILL scientists, students and visitors in a number of activities including data analysis, instrument simulation and sample simulation.

All Software

Version 4.2. (1999)

Non-linear fitting algorithms usually begin with a starting guess for the function parameters that minimize some target function (usually chi squared), and then attempt to improve upon the initial values by an iterative procedure. Different algorithms do this in different ways, and may also estimate the resulting uncertainties in the parameter values obtained in different ways. You can supply your own fitting routines which allows you to determine both the minimization algorithm and the target function.

The Gradient routine supplied with Mfit is adapted from the Levenberg-Marquardt algorithm <tt>leasqr.m</tt> by Richard I. Shrager, A.Jutan, and Ray Muzic. A <tt>simplex</tt> method adapted from the matlab <tt>fmins</tt> function is also provided. Des McMorrow has also written a FORTRAN .mex file interface to the excellent CERN package MINUIT, but this is machine dependent, and so is not included.

Function format

Fitting routines are .m files (or .mex files - see the Matlab external interface guide) with the syntax:

<tt>function [p, std]=function_name(x,y,err,pin,dpin,func)</tt>

The input parameters are:

• <tt>x</tt>, <tt>y</tt>, <tt>err</tt> - vectors containing the data. <tt>err</tt> is the unceratinty in <tt>y</tt>
• <tt>pin </tt>- vector of initial parameter values
• <tt>dpin </tt>- vector the same length as pin. If pin(n)=0 then parameter n is held at the <tt>same value during the fit</tt>
• <tt>func - </tt>the name of the fitting function called. (See 'Writing fitting functions' for details)

and the function returns <tt>p</tt> and <tt>std</tt>, vectors containing the best fit estimates of the paramters, and the associated uncertainties respectively.