Genetic Curvefitting for IGOR PRO

From Motofit

Jump to: navigation, search

The GenCurveFit XOP enables IGOR Pro to use Genetic Optimisation (more specifically Differential Evolution) to curvefit data.

Genetic Optimisation is a valuable technique for finding global best fits, as it is has a high probability of finding the best solution, even if the starting guesses for the fit are poor. In contrast other fitting techniques, such as Levenberg Marquardt, are gradient based, and can often fall into local minima if poor starting guesses are used.

It uses the algorithm of Storn and Price, as detailed in Wormington et. al (1).

The GenCurvefit XOP has been designed to use the same syntax as much of IGOR's curvefit operation. Thus, its learning curve is small. However, its output may be subtly different. GenCurveFit is accompanied by an Igor Help File, which should explain most questions.

Contents

Obtaining GenCurvefit

The pre-compiled XOPs are available from, as well as its sourcecode may be obtained from either the sourceforge site or at the IGOR exchange site. Both Windows and Mac Universal binaries are available. The latest, bleeding edge versions of the package is available from the subversion repository

Installation

  1. Download the XOP.
  2. Unzip the package and place GenCurveFit.xop and GenCurveFit help.ihf somewhere on your harddrive.
  3. Create a shortcut (alias) to GenCurveFit.xop and place it in the \Igor Pro Folder\Igor Extensions folder.
  4. (Re)start IGOR.
  5. If you wish to use the curvefitting GUI then load the geneticoptimisation.ipf procedure file. Access the GUI by selecting Motofit->Genetic Curvefitting. (to load this at IGOR startup place a shortcut to the ipf file in the IGOR procedures folder)
  6. If you want to perfom Simulataneous fitting then also load up Motofit globalfit2.ipf. This will allow you to simultaneously fit multiple datasets using linked parameters.

Screenshots

FAQ

Refer to the XOP help file as a first port of call. (extra questions will be answered here if/when they are asked)

Example

Enter the following code in the procedure window (Ctrl-J) to create a user-defined Gaussian Fit Function:

Function mygauss(w,x):fitfunc Wave w variable x return w[0]+w[1]*exp(-((w[2]-x)/w[3])^2) End

The following code generates a gaussian, then fits it with Genetic Optimisation:

Make/O/N=100 GDataX, GDataY, GOutput	// waves for data
GDataX = enoise(10)			// Random X values
GDataY = 3*exp(-((GDataX-2)/2)^2) + gnoise(0.3)		// Gaussian plus noise
Display GDataY vs GDataX			// graph the data
ModifyGraph mode=2,lsize=2		// as dots
Make/O/D limits ={{-1,0,-10,-1},{1,4,10,-1}}	// make the lower and upper limits
Make/O/D coefs = {0,2,1,2			// make the initial coefficients
Gencurvefit /X=GDataX mygauss,GDataY,coefs,"0001",limits		// do the fit
AppendtoGraph fit_GDataY			//graph the fit, output in waveform
ModifyGraph mode(fit_GDataY)=3		//as crosshairs
Output from the genetic curvefit

References:

  1. Wormington, M., Panaccione, C., Matney, K., Bowen, D.L., "Characterization of structures from X-ray scattering data using genetic algorithms", Phil. Trans. R. Soc. Lond. A. (1999) 357, 2827-2848.
Personal tools