# Curve Fit Inspector

This function allows you to fit data with some predefined functions or free defined functions. Fits are possible with up to 24 functions each with up to 5 free parameters. (read the sources for detailed description how the curve fit function works).

To start a fit two things are necessary. 1. the function(s) you will fit and 2. the start parameters for the function(s). Fitting will only work if the function you provide will match the data of your buffer otherwise the fit will not succeed and you will see an error message. Fitting work better the closer the start parameters match the data.

The *Curve Fit Inspector* consists of a few controls and a table for the function and fit parameter definition.

Active functions are displayed with a check mark in the first column. Double clicking the first column changes the state.

**Function**: In this column you have to define the function you want to fit (see below).

**A**, **B**, **C**, **D**, **E**: This are the free parameters for the fit function.

**Weight**: The weight of a function for the integration routine (only used by the special functions).

**%**: The result of the integration will be displayed in this column (only calculated for the special functions).

**Start**: Starts the fit for the current working buffer.

**Preview**: Displays all the fit functions and the summary curve in the current document.

**Back**: Every time you start a fit the state will be saved in a history buffer. With this button you can go back trough the fit steps.

**Load**: Loads fit data from another document.

**Export**: Allows to export fit results as new buffers to the document.

**All**: Exports all the fit functions and the summary curve as new buffer to your document.

**Summary**: Exports the summary curve as new buffer to your document.

**Points**,

**Min**,

**Max**: Defines the range and the number of points for curve export. If this fields are empty for each point in the current working buffer a new value will be calculated.

**Iteration Limit**: Defines a cycle limit after which it is possible to stop the fit.

**Runtime Preview**: If this button is checked a preview will be displayed after each fit cycle.

**Set Values by Mouse**: If this button is checked the values from the mouse mode *Measure* will be sent to the currently selected line in the parameter table (A = X position and B = Y position). After this the next line in the parameter table will selected automatically. This makes it easy to predefine a bunch of peaks.

## Fit result

The text field in the middle of the inspector shows the status and the result of the fit. The first line displays the fit state and the second the fit result:

**rms**: Root mean square deviation of the last cycle:

**chi-square**:

*sigma*is the error of your data. If your data set doesn't contain error values

*Plot*makes a statistically approximation of the standard deviation.

## Function definition

In the *Function* column you can enter normal mathematical expression as functions for fit (there are some special functions, see below).

Available variables:

x | x value |

A | A parameter |

B | B parameter |

C | C parameter |

D | D parameter |

E | E parameter |

`Example: (x+A)^2+B`

For the 5 fit parameter (A,B,C,D,E) the following syntax is possible:

<value> | a fixed value |

<value>~ | a value which should be fitted |

<value>~<dvalue> | a value which should be fitted in the range from value-dvalue to value+dvalue |

<row>[+,-,*,/]<rel> | sets value in relation to an entry of same column in a previous row |

`Examples: 284 1234~ 10.7~0.2 1-2.3 5*0.12`

## Special Functions

The fit function supports some special functions. These functions are easy to use and a little bit faster than free defined functions. The special functions can not be used together with other expressions in one row.

**GL (Gauss-Lorentz mix curve)**

A = position (x_{0})

B = height (I_{0})

C = width ( α, FWHM)

D = Gauss-Lorentz ratio ( M ,1.0=pure Gauss, 0.0 = pure Lorentz)

E = unused

**DS (Doniach-Sunjic curve)**

n=0.588468, k=1 (right skew) or -1 (left skew)

A = position (x_{0})

B = height (l_{0})

C = width ( γ, Lorentzian FWHM)

D = Anderson's exponent ( α, -0.5 ... 0.5)

E = unused

**ET (Gauss-Lorentz mix curve with exponential Tail)**

A = position (x_{0})

B = height (I_{0})

C = width ( γ, Lorentzian FWHM)

D = Gauss-Lorentz ratio ( M ,1.0=pure Gauss, 0.0 = pure Lorentz)

E = tail exponent factor ( α, -infinity - +infinity)

The numerical Gauss convolution of the following two functions (Lorentz and Doniach-Sunjic, F(Y_{0}, x_{0}, γ, [α]) ) in the interval x_{1} to x_{n} in steps of d_{x} is performed with the following formula:

G is the FWHM of the convoluting Gauss function; y_{0}, x_{0}, γ, [α] are the parameters of the function to be convoluted, as in the earlier expressions for Lorentz and Doniach-Sunjic functions. The normalizing factor Q_{y0} and shift d_{x0} are defined as Q_{y0}=y_{0} / y'_{0} and dx0=x'_{0} - x_{0}, where y'_{0} and x'_{0} are the amplitude and position of the maximum of the not normalized convoluted function.

**GL* (Gauss convoluted Lorentz curve)**

A = position

B = height

C = width (FWHM)

D = Gauss-Lorentz ratio (must be set to 0.0)

E = Gauss FWHM (0 - +infinity)

**DS* (Gauss convoluted Doniach-Sunjic curve)**

A = position

B = height

C = width (Lorentzian FWHM)

D = Anderson's exponent (-0.5 ... 0.5)

E = Gauss FWHM (0 - +infinity)