Curve Fitting
Curve fitting (linear and non-linear)
A number of least squares curve fitting methods can be selected:
- A general (non-linear) Levenberg-Marquardt method to fit your data to any continuous function you define. Just select data from the grid, define your model function, select the constants in this function for which you want a least squares fit and push the Go button.
- Fit to one of the predefined functions such as: linear regression, polynomials, trigonometric polynomials and cubic splines.
- Linear combination of Functions, defined in the Functions window, and Data selected in a Data grid 2. The observed data for which you want a least squares fit are given in Data grid 1.
Levenberg-Marquardt (non-linear) Curve Fitting
The example given below illustrates a fit to data from a Fermi distribution:
This example is made in the following steps:
- The Function was defined and drawn for constant values: a=4, b=0.5, c=2
- Data points were read into the data grid by clicking on the graph (after pushing the “Read data from the graph” button in the Extra tab on the Data panel
- Go back to the Function panel and select the constants (in this case a, b and c) for which you want to find a least squares solution to the data. Give them an appropriate initial value. Note that you may select more than one constant by using the Ctrl or Shift Button.
- Select the Data from the Data grid and plot them
- Finally open the Curve Fitting panel, select Levenberg-Marquardt and press Go. The resulting solution is drawn in the graph and the results together with some statistics of the residuals are shown in the Results window.
Non-continuous functions or complicated periodic functions are difficult to fit. Such functions require special fitting algorithms. As an experiment define and plot the singular function 1/(x+b) for b = – 5 in the interval [0,10]. Read some points from the graph and try to find a fit with Levenberg-Marquardt. Then try to fit it with the 4th or 5th entry in the Curve Fitting list box.