Fitting

From LabRPS Documentation
Revision as of 15:36, 8 August 2022 by LabRPS (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Fitting can be done in two ways:

  • A general Fit Wizard which allows us to use complex functions and to adjust the fitting parameters.
  • A set of simplified fitting dialog boxes for most used functions like exponential growth or decay, etc.

Fitting with Wizard

This function can be accessed by the Fit Wizard command of the Analysis-plots menu when a plot is selected, or the Analysis-tables menu when aa table window is selected. In the latter case, this command first creates a new plot window using the list of selected columns in the table.

This Command is used to fit discrete data points with a mathematical function. The fitting is done by minimizing the least square difference between the data points and the Y values of the function.

If the data points are modified, the fit is not re-calculated. Then, you need to remove the old fitted curve and to redo the fit with the same function and the new points.

The top of the dialog box is used to choose a function among the one which is already defined. Four types of functions are available: the user-defined functions which have been saved, the classical functions proposed by LabRPS in the analysis menu, the simple elementary built-in functions, and external functions via plugins.

To choose one of these functions, you just have to select it and to click on the checkbox under the selector.

If you want to define your own function, you can use the bottom half of the dialog box. You can write your own mathematical expression or add expressions obtained with the function selector. Then you need to define the parameters which have to be fitted in a comma-separated list.

Fitting wizard.png

The second step is to define the parameters for the fit. You have to give an initial guess for the fitting parameters.

Fitting wizard params.png

In this second tab, you can also choose a weighting method for your fit (the default is No weighting). The available weighting methods are:

  • Instrumental: the values of the associated error bars are used as weighting coefficients. You must add Y-error bars to the analyzed curve before performing the fit.
  • Statistical: the weighting coefficients are calculated as the square-roots of each data point in the fitted curve.
  • Arbitrary Dataset: you have the possibility to set the weighting coefficients using an arbitrary data set. The column used for the weighting must have a number of rows equal to the number of points in the fitted curve.

After the fit, the log window is opened to show the results of the fitting process.

Depending on the settings in the Custom Output tab, a function curve (option Uniform X Function) or a new table (if you choose the option Same X as Fitting Data) will be created for each fit. The new table includes all the X and Y values used to compute and to plot the fitted function and is hidden by default, but it can be found and viewed with the project explorer.

The results are shown in the log window, the curve is plotted in the active window, and a table is created to store the fit.

Fitting polynomial result.png

Fitting to specific curves

LabRPS includes quick access to the most useful functions for fitting. Beware that when you use these commands, LabRPS uses default values as initial guesses for the parameters. Therefore, the convergence may be difficult or even impossible if these initial values are too far from the final values. In this case, you can use the Fit Wizard command or the Fit Wizard command, select the function in the built-in set, and give good initial values for parameters.

Fitting Line

This command is used to fit a curve that has a linear shape. The results will be given in the Log window.

Fitting linear result.png

Fitting Polynomial

This command is used to fit a curve that has a linear shape. The results will be given in the Log window.

Fitting polynomial result.png

Fitting to a Bolzmann function

This command is used to fit a curve that has a sigmoidal shape. The function used is:

in which A2 is the high Y limit, A1 is the low Y limit, x0 is the inflexion point and dx is the width.

Fitting bolzman result.png

Fitting to a Gauss function

This command is used to fit a curve that has a bell shape. The function used is:

in which A is the height, w is the width, xc is the center, and y0 is the Y-values offset.

Fitting gauss result.png

Fitting to a Lorentz function

This command is used to fit a curve that has a bell shape. The function used is:

in which A is the area, w is the width, xc is the center, and y0 is the Y-values offset.

Fitting lorentz result.png

Multi-Peaks fitting

This kind of fitting allows you to fit your data points to a sum of N Gaussian or Lorentzian functions. The first step is to specify the number of peaks. Then you must define the position of each peak on the curve. This is done by selecting one data point on the plot, then validate your choice for each peak with the ENTER key.

Fitting multipeak gauss result.png