Curve Fitting
Curve Fitting
Curve Fitting
Before You Begin
Selecting the Active Data Plot
When performing linear or nonlinear fitting when the graph window is active, you must make the desired
data plot the active data plot. To make a data plot active, select the data plot from the data list at the
bottom of the Data menu. The data list includes all the data plots in the active layer. The currently active
data plot is checked.
Selecting a Range of a Data Plot
To select a range of a data plot for fitting, click the Data Selector tool
on the Tools toolbar. Data
markers display at both ends of the active data plot. Additionally, the Data Display tool opens if it is not
already open.
To mark the data segment of interest, click and drag the markers with the mouse. You can also use the left
and right arrow keys to select a marker. The CTRL + left or right arrow keys move the selected marker to
the next data point. Holding both the SHIFT and CTRL keys while depressing the left or right arrow keys
moves the data markers in increments of five along the data plot. (Note: If your X data is not sorted, you
may need to sort the data before selecting a range. To do this, activate the worksheet and select
Analysis:Sort Worksheet:Ascending.)
As with the Data Reader tool, you can press the spacebar to increase the cross hair size.
After you have defined the range of interest, press ESC or click the Pointer button
toolbar.
on the Tools
Any fitting operations you perform on this data plot will apply to the selected region only.
To hide the data outside this range, select Data:Set Display Range.
To remove the selection range, select Data:Reset to Full Range.
The Results Log
Origin automatically routes results from most fitting operations to the Results Log. For a complete
discussion on the Results Log, see Data Analysis.
Linear Regression
To fit a straight line to the active data plot, select Analysis:Fit Linear. With the X data, the independent
variable, and the Y data, the dependent variable, the estimated linear regression model is stated:
Yi = A + BX i
where the parameters, A and B , are estimated by the method of least squares.
A is the intercept: A = Y B X
B is the slope:
After the fitting, Origin creates a new (hidden) worksheet containing the fitted data, and plots this data in
the active graph window. Additionally, Origin copies the following parameters to the Results Log.
(y
i =1
( A + Bxi ))
N 2
Polynomial Regression
To perform a polynomial fit on the active data plot, select Analysis:Fit Polynomial. This menu command
opens the Polynomial Fit to Dataset dialog box in which you specify the order (1 through 9), number of
points drawn in the fit curve, and minimum and maximum X values for the fit curve. To display the fit
equation in the graph window, select the Show Formula on Graph check box.
With the X data, the independent variable, and the Y data, the dependent variable, a polynomial regression
model of the k
th
order is stated:
Y = A + B1 X + B2 X 2 + B3 X 3 +....+ Bk X k
After the fitting, Origin creates a new (hidden) worksheet containing the fitted data, and plots this data in
the active graph window. Additionally, Origin copies the following parameters to the Results Log.
Multiple Regression
To perform a multiple regression on worksheet data, highlight the independent variable columns and select
Statistics:Multiple Regression. This menu command opens an Attention dialog box confirming the data
set selection and automatic designation. Click OK to perform the multiple regression.
With the first column in the worksheet assumed to contain the dependent variable values (Y), and the
highlighted columns assumed to contain the independent variables (X), the multiple regression model is
stated:
Y = A + B1 X 1 + B2 X 2 +...+ Bk X k
Origin copies the regression results and the ANOVA table to the Results Log.
Y X 0 t (1 / 2, n 2) s Y X 0
s 2 Y X 0 = MSE [1 / n + ( X 0 X ) 2 / ( X i X ) 2 ]
Y X 0 is the unbiased estimator of the
where
.
X
expected value of Y at 0 . The band will flare out the further it gets from the mean.
Select the Prediction Bands check box to plot upper and lower prediction band data plots with the fitting
{ }
curve. The prediction band is calculated as Y X 0 t (1 / 2, n 2) s pred
s 2 { pred } = MSE + s 2 Y X 0
Click Fit to perform a linear regression on the selected data plot according to the tool settings. If a
worksheet is active, the highlighted Y column is used as the dependent variable. The associated X column
is used as the independent variable. If a graph window is active, the regression is performed on the active
data plot. After the fitting, Origin creates a new (hidden) worksheet containing the fitted data, and plots
this data in the active graph window. If the data set has not yet been plotted, a new default graph window
opens with the selected Y data set (and its associated X data set, row number, or incremental X value) and
fitting data plotted in layer 1. Additionally, Origin displays the fitting results in the Results Log.
When the Simple radio button is selected , the following results are reported:
Linear Fitting Using the Tools 515
Note: The Polynomial Fit tool now reports confidence intervals on the fit parameters when the Advanced
radio button is selected. The confidence intervals can be checked to determine if their slope is significantly
different from unity. If the confidence interval contains the number 1, then the conclusion would be that
the slope is not significantly different from unity.
The formula for calculating the confidence intervals on the fit parameters is: (fit parameter value) +/(standard error on parameter value) * ttable(significance level, degrees of freedom)
The significance level is given by (1- (1-alpha)/2), where alpha is the confidence level. For example, if
you set the confidence level to 95, then the significance level will be (1-(1-0.95)/2) = 0.975. The ttable
should then be calculated as ttable(0.975,DOF).
The Operation Tab
When the Use Reduced Chi^2 check box is selected, the error on the fit parameters are multiplied by the
square root of the reduced chi-squared. In this case, the error on the fit parameters is calculated as
SQRT(covii*(ChiSqr/DOF)).
Y X 0 t (1 / 2, n k ) s Y X 0
s 2 Y X 0 = MSE [1 / n + ( X 0 X ) 2 / ( X i X ) 2 ]
Y X 0 is the unbiased estimator of the
where
.
X
{ }
expected value of Y at 0 . The prediction band is calculated as Y X 0 t (1 / 2, n k ) s pred
s 2 { pred } = MSE + s 2 Y X 0
exact fit equation that resulted from the fitting process is used to compute the Y value for the given X
value. You can specify any X value inside or outside of the range of the data set or the fit line for
computing the Y value.
To find an X value for a given Y value, you should enter the Y value in the bottom text box next to the
Find Y button and then press Find X. When this action is performed, an iterative procedure is used to find
the X value corresponding to the given Y value:
1) First a check is performed to see if the Y value you specified is inside the range of Y values corevered
by the fit line. If not, no computation is done and you are informed that your Y value is out of range.
2) If the Y value passes this check, then the following steps are performed:
=> The fit line data set is scanned to find two points (X1,Y1) and (X2, Y2) such that the user-specified Y
value lies in the interval [Y1, Y2]. In the case of a fit line that is not monotonic (.ie. multiple X value exist
for same Y value), the first interval that satisfies this criterion, starting from the lower end of the X axis, is
selected.
=> The X value of the mid point of this interval is computed: Xm = (X1 + X2) / 2, and the corresponding
y-value, Ym, is computed using the exact fit equation
=> The interval to the right or left of this midpoint is chosen such that the user-specified Y value now falls
within the new interval.
=> This bisectional search is continued till the y-value of the mid point of the interval, Ym, differs from
the user-specified Y-value by less than 0.00001%, or until 200 iterations are performed, whichever comes
first.
=> The Xm value corresponding to the final Ym value is reported as the X value corresponding to the yvalue you specified.
i2 .
i =1
[ y i ( a + bx i )] 2
i
= wi [ y i ( a + bx i )] . This is
N
i =1
1
. Using the Linear Regression toolbar, you
i2
1
, where si is the error bar for yi . If you do not make this choice, Origin will carry out a
si2
fitting with equal weights, assuming all the i are equal. This can be done by setting i = 1 .
can set wi =
i =1
n
i =1
2
i
i =1
i =1
i =1
i =1
i =1
sx
sy
, y
, and wTotal = wi .
wTotal
wTotal
i =1
SXY
.
SXX SYY
SXY
, and a = y bx with standard errors
SXX
1
sd
x2
, and se( a ) = sd
+
. sd =
wTotal SXX
SXX
se(b) =
RSS
is the estimated
df
2.
The (1 ) 100% confidence interval (confidence band) for the mean of Y is given by:
Y = bx t ( 2, n 2) sd
3.
1
( x x )2
+
.
wTotal
SXX
RSS
. COD is also called R-squared since COD
SYY
n 1
= 1 [1 r 2 ]
.
df
4.
Mean Squares
(MS)
Regression
SSreg=SYYRSS
MSreg=SSreg/1
MSreg/MSE
Residual
n-2
RSS
MSE=RSS/(n-2)
Total
n-1
SYY
The variable F=MSreg/MSE follows an F distribution F(1,n-2). The P-value can be obtained from the F
distribution.
sxy
sd
, with standard error se(b) =
. sd =
sxx
sxx
RSS
is the
df
estimated standard deviation of the fitting, df = n - 1, and the residual sum of squares is
n
RSS = wi [ yi bxi ]2 .
i =1
2) The (1 ) 100% confidence interval (confidence band) for the mean of Y is given by:
x2
Y = a + bx t ( 2, n 1) sd
.
sxx
3) The ANOVA for the fitting is summarized in the following table:
Degree of
Freedom
Sum of
Squares (SS)
Mean Squares
(MS)
Regression
SSreg=SYYRSS
MSreg=SSreg/1
MSreg/MSE
Residual
n-1
RSS
MSE=RSS/(n-1)
Total
SYY
The variable F=MSreg/MSE will follow an F distribution F(1,n-1). The P-value can be obtained from the
F distribution.
resi = yi (b0 + b1 x i + b2 x i2 +......+ bk x ik ) have normal (Gaussian) distributions with the mean = 0
and the variance =
i2 .
Then the maximum likelihood estimates for the parameters b[i] can be obtained by
N
2 =
i =1
i = 1.
resi2
i2
b0
b
1
b = ,
bk
A=
~
A Y , where
x1k
y1
1
1
, Y =
x nk
yn
n
n
w res
i
2
i
i =1
sd =
RSS
, and df = n - (k + 1).
df
Mean Squares
(MS)
Regression
SSreg=SYYRSS
MSreg=SSreg/k
MSreg/MS
E
Residual
n-(k+1)
RSS
MSE=RSS/(n-k-1)
Total
n-1
SYY
The variable F=MSreg/MSE will follow an F distribution F(k,df). The P-value can be obtained from the F
distribution.
X1 [i] X 2 [i]
the dependent variable, and all other X columns to be the independent variables. We fit the model:
Y = b0 + b1 X1 +......+ bk X k , assuming the residuals resi = yi (b0 + b1 x1i + b2 x 2 i +......+ bk x ki )
have normal (Gaussian) distributions with the mean = 0 and the variance = . Then the maximum
likelihood estimation for the parameters b[i] can be obtained by minimizing the chi-square
2
2 = resi2
i =1
b0
b
1
b = , A =
bk
1 x11
1 x n1
~
AY
x k1
y1
, Y =
x kn
yn
res
2
i
i =1
2)
sd =
RSS
is the estimated standard deviation of the fitting and df = n - (k + 1).
df
Mean Squares
(MS)
Regression
SSreg=SYYRSS
MSreg=SSreg/k
MSreg/MS
E
Residual
n-(k+1)
RSS
MSE=RSS/(n-k-1)
Total
n-1
SYY
The variable F=MSreg/MSE will follow an F distribution F(k,df). The P-value can be obtained from the F
distribution.
y = y0 + A1e x / t1 , where
y0
Y offset
A1 amplitude
t1
decay constant
When you select this menu command, Origin makes the necessary initialization for the parameters. Origin
also sets y0 to an appropriate fixed number which is close to the asymptotic value of the Y variable for
large X values.
Note: When fitting from the menu, all the parameters by default vary during the iterative procedure. If
you want to fix certain parameters to particular values, you must open the curve fitters dialog box.
y = y0 + A1e x / t1 + A2 e x / t2
This menu command opens the Verify Initial Guesses dialog box in which you specify initial values for the
fitting parameters.
Fitting to multiple exponentials is more difficult than fitting to a single exponential. You must make good
guesses for the fitting parameters. You may need to enter the nonlinear fitting session to get better control
for the fitting.
Note: To learn more about second order exponential decay fitting, review the EXP DECAY.OPJ project
located in your Origin \SAMPLES\ANALYSIS\CURVE FITTING folder.
y = y0 + A1e x / t1 + A2 e x / t2 + A3e x / t3
This menu command opens the Verify Initial Guesses dialog box in which you specify initial values for the
fitting parameters.
Exponential Growth
Select Analysis:Fit Exponential Growth to fit a curve to the active data plot, using the equation:
y = y0 + A1e x / t1 , where
y0 Y offset
A1 amplitude
t1
time constant
Gaussian
Select Analysis:Fit Gaussian to fit a curve to the active data plot, using the equation:
y = y0 +
A
w
2( x x 0 )
w
, where
y0 baseline offset
A
This model describes a bell-shaped curve like the normal (Gaussian) probability distribution function. The
center x 0 represents the mean, while w 2 is the standard deviation.
Lorentzian
Select Analysis:Fit Lorentzian to fit a curve to the active data plot, using the equation:
y = y0 +
2 A
w
4( x x 0 ) + w 2
2
, where
y0 baseline offset
A
The parameters in the Lorentzian model are similar to the parameters defined for the Gaussian model.
Sigmoidal
Select Analysis:Fit Sigmoidal to fit a curve to the active data plot using either the Boltzmann or Logistical
equation.
Boltzmann Equation
When the X axis is set to linear scale, the Analysis:Fit Sigmoidal menu command uses the Boltzmann
equation for fitting:
y=
A1 A2
+ A2
1 + e ( x x0 )/ dx
, where
x0 center
dx width
A1 initial Y value: y ( )
A2 final Y value: y ( +)
The Y value at x0 is half way between the two limiting values A1 and A2 : y ( x 0 ) = ( A1 + A2 ) 2 . The
Y value changes drastically within a range of the X variable. The width of this range is approximately dx.
Logistical Equation
When the X axis is set to a logarithmic scale, the Analysis:Fit Sigmoidal menu command uses the
Logistical equation for fitting:
A1 A2
1 + ( x / x0 )
+ A2
, where
x0 center
p
power
A1 initial Y value
A2 final Y value
The Y value at
Leave the Reduced Chi^2 check box selected when there are no associated error bars with the data (which
is the default - and only - option). In this case, the error on the fit parameters is calculated as
SQRT(covii*(ChiSqr/DOF)).
Leave the check box cleared when the data has associated error bars and a weighting method other than
None has been chosen by you. This is the default, and recommended setting for this check box. The error
on the fit parameter is then calculated as SQRT(covii).
When the data has associated error bars and a weighting method has been chosen by you, you have the
option to select the check box, thereby multiplying the reported error on the fit parameters by the square
root of the reduced chi-squared. In this case, the error on the fit parameters is calculated as
SQRT(covii(ChiSqr/DOF)).
The Logged Data Fit Function Group
Select either the Boltzmann or Dose Response (logistic) function to fit logged data (for example, 10^7
plotted as 7).
Note: If the X axis scale is set to Log10, the Dose Response (logistic) function is always used,
independent of your radio button selection.
The Weighting Group
Select the None, Error Bars, or Inverse Y weighting radio button. If you select the Error Bars radio button,
you must have selected a Y error bar column with your Y column in a worksheet, or plotted your data with
error bars in a graph. In this case, Origin uses 1/errbar^2 as the weighting. For inverse Y weighting,
Origin uses 1/Y where Y is the data that is being fitted to.
Multiple Gaussian
Select Analysis:Fit Multi-peaks:Gaussian to fit a curve with multiple Gaussian peaks to the active data
plot. This menu command opens the Number of Peaks dialog box in which you type a value for the
Nonlinear Curve Fitting from the Menu 531
number of peaks. Click OK to close the dialog box. This action opens the Initial Half Width Estimate
dialog box. Additionally, Origin estimates the overall half-width through integration, and then divides by
the number of peaks to arrive at the half-width estimate. Modify or accept the estimated value in the Initial
Half Width Estimate dialog box. Click OK to close the dialog box. The Data Display tool opens if not
already open. To read the XY coordinates of a data point in the Data Display tool, click on the desired
point. To determine a peak position, double-click (or click + ENTER) on a data point. When complete,
the fitting parameters, as well as related statistics, are displayed in the graph window and the Results Log.
Additionally, the fit data is copied to a new (hidden) worksheet.
Multiple Lorentzian
Select Analysis:Fit Multi-peaks:Lorentzian to fit a curve with multiple Lorentzian peaks to the active
data plot. This menu command is similar to the Multiple Gaussian menu command as it allows you to
specify the number of peaks, and then invokes fitting to multiple Lorentzian functions.
F=
4) Once the F value is computed, Origin calculates a p-value using the formula:
the wizard map. When this page is skipped when you run your customized wizard, the wizard will
automatically perform the action.
The following actions can be saved to a custom wizard:
Select Data page: No actions are saved on this page. However, you can hide and skip this page because
the active data set is used by default.
Select Function page: No actions are saved on this page. Thus, you cannot hide and skip this page.
Peaks page: No actions are saved on this page. You can only hide and skip this page if your data set has a
single peak.
Weighting page: This page can only be hidden and skipped if your weighting method is set to None,
Instrumental, or Statistical - because Arbitrary and Direct require a data set selection.
Fitting Control page: This page can be hidden and skipped. However, only the Iteration button is
recorded. The Chi^2 button is non-recordable.
The following settings are saved to the NLSF.INI file:
Tolerance
Default for the Iterations drop- down list and button
The following settings are saved to the NLSFwizard.INI file:
Confidence Spin/Edit
Prediction Spin/Edit
Results page: You cannot hide and skip this page.
Note: A number of settings are saved globally and are independent of custom wizards. These include the
tolerance and iterations settings which are saved to the NLSF.INI file. Additionally, the confidence and
prediction settings, as well as many other wizard settings, are saved as global settings in the
NLSFWizard.INI file. Open either initialization file in a text editor to view the settings.
After clearing the desired wizard map check boxes, perform the following steps to create your custom
wizard:
1) On the Results page, select the Save Fitting Session as a Procedure File check box.
2) Right-click again on a blank section of the wizard and select View Mode:Normal from the shortcut
menu. The wizard map updates displaying only the non-hidden pages.
3) Click the Finish button. This action opens the Button Settings dialog box.
This dialog box allows you to save your current wizard settings and actions to a new toolbar button.
When the Button Settings dialog box opens after you click the wizard's Finish button, the top left button in
the dialog box will be depressed. You can assign your custom wizard settings to this button or you can
select another button. Note: This dialog box does not recognize if a bitmap button is already in use.
You can specify a ToolTip and status bar message for your button.
After you click the OK button, Origin adds this button to a new NLSFWiz toolbar.
only) or (iii) write your own Origin C code to calculate dataset-specific parameter estimates for your userdefined functions
2) Impose linear constraints on the values of parameters.
3) Monitor the relevant quantities during the iterative process which may indicate ill-behaving functions.
4) Select the weighting method.
5) Easily set the fitting data range, etc.
Note: The NLSF always reports the reduced chi^2 value, not chi^2. In some locations of the NLSF,
reduced chi^2 is labeled "chi^2". In other locations, it is labeled "chi^2/DoF". In all cases the actual value
is reduced chi^2.
Fixing Parameters
Suppose that you want to fit the data to the exponential decay function but with a fixed value of the vertical
offset y0 (=4).
1) Type 4 in the Value text box for the y0 parameter. Clear the Vary check box for this parameter.
2) Type 0.01 in the Value text box for the x0 parameter. Leave the Vary check box selected.
3) Type 8 in the Value text box for the A1 parameter. Leave the Vary check box selected.
4) Type 8 in the Value text box for the t1 parameter. Leave the Vary check box selected.
Performing Iterations
1) Click 1 Iter to perform one iteration. New values of the parameters x0, A1, and t1 are displayed
together with the current value of the reduced chi^2. Notice that the parameter value of y0, which we fixed
in the previous step, remains unchanged. The theoretical curve corresponding to the current parameter
values is displayed in Graph1.
2) Click 100 Iter to perform (at most) 100 iterations. Notice the improvement of the fit.
Finishing Fitting
1) Click Done. The fitters dialog box closes. The parameter values are pasted to the graph.
VariableName is the name of the variable. Indep or Depend specifies whether the variable is independent
or dependent. DatasetAssignment is the name of the data set to which the variable is assigned. Range is
the data set range used in fitting.
If no data set assignment has been made, the associated section of the line displays question marks. This
field updates during data set assignment.
The Available Datasets List Box
This list box displays the names of all the data sets in the project.
The Assign/Assign X Buttons
You must assign all the variables to data sets.
The way in which you assign variables to data sets differs depending on whether you are assigning a
dependent or an independent variable.
To assign dependent variables to data sets:
1) Click on the dependent variable you want to assign in the Variables:Datasets list box. The row
becomes highlighted. Additionally, the Assign X button becomes unavailable.
2) Click on the data set name you want the variable assigned to in the Available Datasets list box. The
data set becomes highlighted.
3) Click Assign to assign the variable to the data set.
To assign independent variables to data sets:
1) Click on the independent variable you want to assign in the Variables:Datasets list box. The Assign X
button becomes available.
2) Click on a data set name in the Available Datasets list box.
3) There are now two options. If you want the variable assigned to the data set which you highlighted in
step b, click Assign. If you want the variable assigned to the x of the data set which you highlighted in
step b (rather than to the data set itself), click Assign X. The x of a data set may have three different
meanings: another data set; the data sets associated row numbers, or a defined starting value and a step
increment.
Fitting Step Size Text Box
Specify whether you want to skip some points in fitting in this text box. For example, type 3 to use every
third point in the data set. Type 1 to use all the data points.
The <= and <= Text Boxes
If a dependent variable is highlighted in the Variables:Datasets list box, use '<= Row <=' text boxes to
specify the interval of data set rows to be used in fitting.
If an independent variable is highlighted in the Variables:Datasets list box, then the space between the two
<= signs turns into a button. You can toggle the words Row or <name of variable> on this button. If
Row is selected, the meaning is the same as for dependent variables. If the name of the independent
The Nonlinear Least Squares Fitter 541
variable is displayed on the button, specify the interval in units of the independent variable to be used for
fitting. For example, if you have specified 3.1<=x<=9.7, this means that only the points with the value of
the independent variable X between 3.1 and 9.7 will be used in fitting.
Some General Notes on the Advanced Mode of the Nonlinear Least Squares
Curve Fitter
The fitting menu bar includes five menus: Category, Function, Action, Options, and Scripts. Each of
these menus contain several commands. In most cases, when a menu command is selected, the dialog box
associated with the menu command is displayed in the fitting window. In addition, a fitting toolbar
containing twelve buttons displays below the menu bar. Each button is associated with a menu command
and can be clicked on to open the respective dialog box. You can toggle the toolbar on and off by
(de)selecting Options:Toolbar from the fitters menu.
Menu commands (and the corresponding toolbar buttons) may be temporarily disabled. For example, you
cannot select the Action:Fit menu command unless you have already selected or defined a fitting function.
The menu command corresponding to the dialog box currently displayed in the fitting window is checked.
The fitting dialog boxes contain buttons, text boxes, drop-down lists, check boxes, and list boxes. Settings
in one dialog box often reflect settings in other dialog boxes. For example, you can initialize parameters in
the Initializations dialog box. If you then select Action:Fit, the parameter values displayed in the Fitting
Session dialog box reflect those set in the Initializations dialog box.
An Example Defining your own Function of Two Variables in the Advanced Mode
This tutorial teaches you how to define your own function of two variables to fit sample data sets using the
advanced mode of Origins NLSF. You will write and compile your function using Origin C. The
function to be defined is:
act = vm * substr / (km + (1 + inhib / k) * substr)
9) From the NLSF menu, select Scripts:After Fit. In the Fit Curve group, select Same X as Fitting
Data (this is necessary because the x variable is not a continuous variable).
10) Verify that the Generate Fit Curve and Paste Parameters to Plot check boxes are selected.
11) From the NLSF menu, select Function:Save. This saves the function along with our settings, for
future use.
y=y0 + (A/(w*sqrt(PI/2)))*exp(-2*((x-xc)/w)^2) .
Opening a Project File
1) Click the Open button
on the Standard toolbar to open the Open dialog box. Select Project
(*.OPJ) from the Files of Type drop-down list.
2) In the Origin TUTORIAL folder, double-click on FITEXMP4.OPJ in the list of files. This opens the
Fitexmp4 project with the Graph1 window displaying sample data.
Starting the Fitter
1) Select Analysis:Non-linear Curve Fit:Advanced Fitting Tool to open the NLSF window.
2) If the basic mode of the fitter is displayed, click More to proceed to the advanced mode.
Selecting a Function
1) Select Function:Select to open the Select Function dialog box.
2) Click on Origin Basic Functions in the Categories list box.
3) Click on Gauss in the Functions list box. This action selects a Gaussian function.
Selecting Multiple Data Sets
1) Select Action:Dataset to open the Select Dataset dialog box.
2) Select the Fit Multiple Datasets check box.
3) Click twice on the Add Data button to indicate that you want to fit simultaneously three data sets to the
same function.
4) Click on the x(1) independent variable in the Datasets:Variables list box at the top of the dialog box to
highlight it.
5) Click on the data1_a data set name in the Available Datasets list box to highlight it.
6) Click Assign to assign the independent variable x(1) to the data1_a data set.
7) Repeat the same procedure with the independent variables x(2) and x(3) to assign them to the same
data1_a data set.
8) Click on the y(1) dependent variable in the Datasets:Variables list box at the top of the dialog box to
highlight it.
9) Click on the data1_b data set name in the Available Datasets list box to highlight it.
10) Click Assign to assign the dependent variable y(1) to the data1_b data set.
11) Repeat the analogous procedure for the dependent variable y(2) to assign it to the data1_c data set and
for the dependent variable y(3) to assign it to the data1_d data set.
process that produced the experimental data. The model usually depends on one or more
parameters p1 , p2 , p3 ,....
The aim of the fitting procedure is to find those values of the parameters which best describe the data. The
standard way of defining the best fit is to choose the parameters so that the sum of the squares of the
deviations of the theoretical curve(s) from the experimental points for a range of independent variables:
( p1 , p2 ,...) =
eff
w [y
ji
ji
y ji
yj
eff
of the independent (input) variables x1 = x1i , x2 = x2i , ...; n is the total number of experimental points
used in the fitting, and p is the total number of adjustable parameters used in the fitting (the difference
d = neff p is usually referred to as the number of degrees of freedom). The quantities w ji represent
the weights of each experimental point. Four different weighting methods are supported by Origin:
No weight:
w ji = 1
Instrumental weights:
Statistical:
w ji = 1 2ji
w ji = 1 y ji
, where
ji
Any data set: The weights are determined by any user-specified data set so that
are the values of arbitrary data sets.
Direct:
w ji = 1 c 2ji
, where
c ji
w ji = c ji
y = f ( x; p1 , p2 , p3 ,...)
the expression for
( p1 , p2 ,...) =
2 simplifies to:
1
eff
w [ y f ( x ; p , p ,...)]
i
2 ( p1 , p2 ,...) by performing a
In order to do
= f / p , f / p ,..., f / p
j
1
j
2
j
p
for all the
that, Origin internally calculates partial derivatives f'j
values of the input variables. For built-in functions, all the derivatives are computed using analytic
expressions. For user-defined functions, the partial derivatives are computed numerically. The
computation is thus faster for built-in functions than for user-defined functions. (Note: You can define a
user-defined function with partial derivatives.)
You can limit the set of the allowed values which the fitting parameters can take during the iterative
procedure by imposing linear constraints. Origin internally implements the constraints by means of the
Lagrange multiplier method.
Note: The NLSF always reports the reduced chi^2 value, not chi^2. In some locations of the NLSF,
reduced chi^2 is labeled "chi^2". In other locations, it is labeled "chi^2/DoF". In all cases the actual value
is reduced chi^2.
1) From the Origin program menu, select Analysis:Nonlinear Curve Fit:Advanced Fitting Tool.
2) From the NLSF menu, select Category:New.
3) In the Category Name text box, type Category Name (spaces are permissible) and click OK.
The External DLL option gives the user access to a function that is coded and compiled using a non-native
compiler (such as a C or Fortran compiler). This method pre-dates Origin C and, as such, is now less
compelling. However, OriginPro customers will find documentation of this method in Section 7.3 (page
340) of the OriginPro manual.
The Number of Parameters Drop-Down List
By default, Origin assigns names of P1, P2 , etc., to function parameters. For example, setting the Number
of Parameters drop-down to 3, generates the parameter names of P1, P2, and P3.
If you opt for user-defined parameter names, it is not necessary to set the Number of Parameters dropdown list.
The User Defined Param. Names Check Box.
This check box must be selected if you specify your own parameter names.
The Parameter Names Text Box
If default parameter names are used, this text box is not editable. It is only editable when the User Defined
Param. Names checkbox is selected.
Note: The following user defined parameter and variable names are not allowed: x1, x2,.xn, y1,
y2,yn, z1, z2,zn, and the letter i. The letters t, j, and e should also be avoided. Furthermore, there are
some system variables that should be avoided. For more information on these system variables, consult the
LabTalk Help file by choosing Help:Programming:LabTalk Reference from the Origin menu. You are
strongly encouraged to choose parameter and variable names that contain more than one character. If
you use a name that is not allowed, you will be prompted to change it when you start fitting.
The Independent Var. Text Box
Specify the name(s) of the independent variable(s), using comma separators as needed. Note that the
NLSF allows more than one independent variable.
See the note above concerning parameter and variable names.
The Dependent Var. Text Box
Specify the name(s) of the dependent variable(s), using comma separators as needed. Note that NLSF
allows more than one dependent variable.
See the note above concerning parameter and variable names.
The Definitions Text Box
The function definition is typed into this text box. If you define your function using Origin C (the Use
Origin C box is check box is selected), it may be more convenient to use the Code Builder workspace to
type your function. Refer to the Edit in Code Builder Button section below for more details. Once you
have defined your function in Code Builder, you can do further editing in the Definitions text box.
If the Use Origin C check box is cleared, you must type the function in the Definitions text box. This
applies to all forms (Expressions, Y-Script, or Equations) available from the Form drop-down list.
The Nonlinear Least Squares Fitter 553
Expression. Use is limited to function definitions with a single dependent variable. The function
definition follows the form of this example:
a*x+b*x^2+exp(c*x)
Y-Script. Use this form when using LabTalk script to define your function. Each dependent variable
must be defined in the script using the form
y =
where y is the dependent variable.
Equations. This option is appropriate for one or more dependent variables. Define your function in
Definitions text box. For multiple dependent variables, type a separate line for each following the
form of this example
y1 = .
y2 = .
where y1 and y2 are dependent variables. Do not include any loops or if-else clauses.
Temporary variables are permissible.
Note: If your function definition uses constants and the constant values are not specified in the function
definition itself, they must be assigned in the Constants text box of the Initialization dialog box (choose
Scripts:Parameter Initialization from the NLSF menu).
The Edit in Code Builder Button
This button is available when Use Origin C is enabled. Clicking this button opens a specialized version of
the Code Builder workspace. This specialized view will open with an active window named
_nlffunctionName.fit (_nlfAsymmetricGaussian.fit, in this example). This is the edit window for the new
function definition.
The first few lines of code are #include statements that identify various header files required for
compiling the fitting function. The actual function definition begins with the statement:
void _nlsfAsymmetricGaussian(
The parameters, independent variables, and dependent variables are declared at the beginning of this
function definition. After these declarations, there is an editable section the area bounded in white that
is reserved for entering your function definition.
The above figure shows the definition of the asymmetric Gaussian function having been typed in. Note
that the function definition must comply with C programming language syntax. For instance, the
parameters and all variable types are case sensitive. Intermediate variables such as B in this example
must be declared first using a statement such as:
double B;
This declaration must occur before the variable is used in the function definition.
Note that the function is of type void, which means that no values are returned by the function. Instead,
the dependent variable value is set inside the function code. In our example, the dependent variable y is
assigned a different value, dependent upon whether x is less than or greater than the centroid parameter, xc.
Once the function is defined, you must verify that your syntax is correct. To test, click the Compile button
at the top of the Code Builder workspace. This action compiles the function code using Origin C. Any
errors generated in the compiling process are reported in the Code Builder output window at the bottom of
the workspace. This window also reports when a file has successfully compiled (see the above figure).
Once the function has been defined and compiled, you can return to the NLSF interface by clicking the
Return to NLSF button at the top of the window. This closes the specialized Code Builder window.
As mentioned, you can do further editing of your function directly in the NLSF Function Definition text
box. You can also click the Edit in Code Builder button and return to the Code Builder workspace to edit
your function.
Note 1: It is not necessary to close Code Builder to return to the NLSF. You can leave the Code Builder
workspace open and switch between the NLSF and Code Builder. However, if you leave Code Builder
open, you will not be able to edit to your function from the NLSF; the NLSF Function Definition text box
will not be editable. Furthermore, if you make changes to your function in the Code Builder workspace,
you should click the Compile Button so that when you switch to the NLSF, your function is updated. We
recommended that you click the Return to NLSF button to close Code Builder before returning to the
NLSF. If you wish to debug the function by setting break points in your code, it makes sense to leave
Code Builder open. For further information on debugging, select Help:Programming:Programming
Guide from the Origin menu and search on debug.
Note 2: If after defining your function in Code Builder you click the Return to NLSF button without
compiling your function, the function will compile automatically when you select Action:Fit from the
NLSF menu.
The Save Button
Click the Save button to save the function as functionName.FDF. The default folder for storing the
function file is the \FitFunc subfolder in the Origin software directory. If a function of the same name
already exists, the Save As dialog box opens and the user is asked to give the function a new name.
Assigning a new name to the function will update the Name field in the Function Name text box.
Note that once you save the function file, the Function Name text box is no longer editable. To change the
name of a saved function, save the function with a different name using the Save As button.
The Save As Button
The Save As button opens the Save As dialog box. The Save As button allows you to save the current
function under another name. Note that choosing another name assigns this name to both the function
name and the disk (.FDF) file. If a function of the same name already exists, the user is prompted to
choose a different name.
The Cancel Button
Click the Cancel button to discard function modifications made since the function file was last saved.
The File Button
Click the File button to display and/or edit the function definition file associated with the function. To
return to the Edit page, click on the Form button.
The Derivatives Check Box
Specifying partial derivatives of your function can reduce the time it takes to perform a set of iterations.
However, given the much-enhanced speed of fitting achieved with Origin C, specifying partial derivatives
may not be necessary.
If you wish to specify partial derivatives, note that you must specify the derivatives of the function of the
dependent variable in terms of the fit parameters. Furthermore, partial derivatives with respect to all fitting
parameters need to be specified.
If you have chosen to define the function using Origin C, the variables for the partial derivatives will be
pre-defined in Code Builder. You just need to enter the expression for them..
For example, if the function is:
y = P1 + P2 * x + exp(P3 * x)
then the variables dy_P1, dy_P2, and dy_P3 will be available, and you will need to enter the following
equations for the partial derivatives:
dy_P1 = 1;
dy_P2 = x;
dy_P3 = x * exp(P3 * x);
Note that if you do not use Origin C and are defining your function using LabTalk with the Form drop
down list set to Y-Script (the only form that is compatible with use of derivatives), then the notation for
partial derivatives is different. In this case, the partial derivatives for the above example would be:
yP1 = 1;
yP2 = x;
yP3 = x * exp(P3 * x);
When using Origin C to define your function, any constant you specify in this text box will appear in the
function body when you edit/view the function in Code Builder. You should define your constants in this
text box before editing your function in Code Builder. This will ensure that your constants appear in your
function definition.
If you are defining your function using LabTalk, with the Form drop-down set to Y-Script, then the
constant(s) you specify in this text box will be available for use in your function definition script.
You can also use externally defined constants in your Y-script function (e.g., constants defined in the script
window). In such cases, you can use the constant in your function definition script, and later assign values
to the constant in the Constants text box.
There same naming restrictions apply to constants as apply to parameter and variable names: x1, x2,.xn,
y1, y2,yn, z1, z2,zn, and the letter i are not allowed. The letters t, j, and e should also be avoided.
Furthermore, there are some system variables that should be avoided. For more information on these
system variables, consult the LabTalk Help file by choosing Help:Programming:LabTalk Reference
from the Origin menu. You are strongly encouraged to choose constant names that contain more than one
character.
The Enable Automatic Parameter Initialization Check Box
This check box determines whether automatic parameter initialization code is executed when you choose
Action:Fit from the NLSF menu. This setting is saved with each function file. If this check box is
cleared, then the user needs to click the Execute button to run the initialization code. For new functions,
this check box is cleared by default. For built-in functions, this check box is selected by default, but can be
cleared at your discretion.
Note: If datsets for fitting are not assigned, the parameter initialization code will fail to execute.
The Use Origin C Check Box
When you create a new function, this check box is selected by default. When this check box is selected,
parameter initialization code must be defined using Origin C. If this box is cleared, the parameter
initialization code is interpreted as LabTalk script. Leaving the check box selected (using Origin C)
optimizes parameter initialization.
The first few lines of code are #include statements that identify various header files required for
compiling the initialization code. The initialization function starts with the statement (for this example):
void _nlsfParamAsymmetricGaussian(
The parameters, independent variables, and dependent variables are declared at the beginning of this
function definition. In addition to these, a few other Origin objects are also declared. A Dataset object is
declared for each of the independent and dependent variables. A Curve object is declared for each xy data
pair.
Dataset x_data,
Dataset y_data,
Curve x_y_curve
The Dataset objects point to the x and y datasets for which you are trying to find a best fit. Therefore, the
Dataset objects should be used in the initialization code without performing any modifications to them;
modifications of the Dataset objects will alter the dataset to be fit.
The Curve object is a copy of the dataset curve that results from pairing an x and a y dataset. You can
manipulate this Curve copy in the initialization code without affecting the fit dataset. Many Origin C
functions take the Dataset or the Curve as an argument and return potentially useful properties (as, for
instance, assigning initial parameter estimates in the initialization code).
Below these declaration statements, there is an editable section the area bounded in white that is
reserved for entering the initialization code. The above figure shows some parameter initialization code for
the asymmetric Gaussian function. Note that the function definition follows the requisite C syntax. Note,
also, that the function is of type void, which means that our function returns no values. Instead, the
parameter variables are stored in the function code. The y0 parameter is initialized using the minimum
value of the y dataset, the xc parameter is initialized using the x value that corresponds to the maximum y
value (centroid of the peak in the data) etc.
Initialization is accomplished by calling built-in functions that take a dataset or a curve object as an
argument. Such functions are prototyped in the data.h header file and the C code for these functions can be
found in the file internal.c, in OriginC\System subfolder.
Once the initialization function is defined, you should verify that the syntax is correct. To do this, click the
Compile button at the top of the workspace. This compiles the function code using Origin C. Any errors
generated in the compile process are reported in the Code Builder Output window at the bottom of the
workspace. The Output window reports that the compilation is successful. (see the above image).
Once the initialization code has been defined and compiled, you can return to the NLSF interface by
clicking on the Return to NLSF button at the top of the workspace. This will close Code Builder and
return you to the NLSF interface. From there, you can do further editing of your code in the Initialization
Code text box or you can click the Edit in Code Builder button again to launch Code Builder.
Note: It is not necessary to close Code Builder to return to the NLSF. You can leave the Code Builder
workspace open and switch between the NLSF and Code Builder. However, if you leave Code Builder
open you will not be able to edit to your code from the NLSF; the Initialization Code text box will not be
editable. Furthermore, if you make changes to your code in the Code Builder workspace, you should click
the Compile Button so that when you switch to the NLSF, your code is updated. We recommended that
you click the Return to NLSF button to close Code Builder, before returning to the NLSF. If you wish to
debug your code by setting break points, it makes sense to leave Code Builder open. For further
information on debugging, select Help:Programming:Programming Guide from the Origin menu and
search on debug.
Note2: If datsets for fitting are not assigned, the parameter initialization code will fail to execute.
The Initialization Code Text Box
This text box contains the parameter initialization code. The code can be edited in this text box, or it can
be edited in Code Builder by clicking on the Edit in Code Builder button. If you make changes to the code
in this text box, you can click the Execute button to compile and execute the code. Compilation errors will
produce an Error during compilation message in the status area at the bottom of the NLSF interface.
Add the Origin C function to your Code Builder workspace. For more information, look up index
entry Workspace, adding files in the Origin 7 Programming Guide
(Help:Programming:Programming Guide from the Origin menu).
2)
Create a header file that prototypes the function(s) that you want to access.
Add this header file to the nlsf.fit template file in your \OriginC\NLSF subfolder .
This is the method by which the parameter initialization functions are included for use in the NLSF. These
functions ( min(), yatxmax(), area() etc.) are defined in internal.c and are prototyped in data.h. The data.h
header file is included in the nlsf.fit template file and so is included any time you code with Origin C in the
NLSF. The internal.c file is a special file that the NLSF loads and adds to your workspace any time you
that compile code with Origin C.
equation into the new function Description text box. Then you can proceed to modify the equation and
save it with a new name.
name and the disk (.FDF) file. If a function of the same name already exists, the user is prompted to
choose a different name.
The Cancel Button
Click Cancel to discard the function modifications in the Edit Function dialog box.
You can edit the parameter values in the associated text boxes as desired. Every new iteration (or set of
iterations) starts from these values.
The Vary Check Boxes
Each parameter contains a Vary check box. Select this check box to vary the parameter value during the
iterative procedure. Otherwise, the parameter remains fixed at its current value.
The Error List Boxes
If at least one iteration has been done, these list boxes contain the estimates of the standard errors. The
= Cii
error is i
C = ( F'F)
(here f is the fitting function for the data set values of the
These list boxes display the parameter dependency. If the equation is overparameterized, there will be
1
mutual dependency between parameters. The dependency for the ith parameter is defined as
If this value is close to one, there is strong dependency.
1
1
Cii Cii .
function is at particular values of the independent variables x1 = x1i , x2 = x2i , ... . You can claim with
100a% confidence that the correct value for the fitting function lies within the confidence interval, where a
is the desired level of confidence. This defined confidence interval for the fitting function f is computed
as:
2
2 f ' Cf
1/ 2
where f
= f / p1 , f / p2 ,..., f / p p
the bi-tail
], d = n
eff
independent variables x1 = x1i , x2 = x2i , ... . This defined prediction interval for the fitting function f is
computed as:
2
2
f ( x1i , x2i ,...; p1i , p2i ,...) td (1 + f ' Cf )
where f
= f / p1 , f / p2 ,..., f / p p
the bi-tail
1/ 2
], d = n
eff
Where F = Ftable(Confidence, 1, N-P) and SSR is the minimum SSR found during the fitting session.
g. Depend: Dependency of the parameter ( a value very close to 1 indicates strong dependency, and
therefore, over parameterization).
h. ConfIntv: Confidence interval. Calculated based on a linear approximation and is given by Standard
Error * t, where t is the critical value of the t distribution for the given confidence level.
The n rows of parameter information are followed by:
a. ChiSquare: reduced chi^2 value of fit.
b. SSR: sum of squares of difference between data and fit values.
c. Correlation: correlation coefficient (R).
d. COD(R^2): Coefficient of Determination (R^2).
e. MuFinal: final value of diagonal magnification of the curvature matrix.
f. MuMin: smallest value of Mu that was ever reaching during fitting.
g. DerivStep: parameter change amount for calculating derivatives (Derivative Delta).
h. ParaChange: the number of parameters that were allowed to vary during fitting.
i. Tolerance: tolerance value to stop iterations.
j. Confidence: value for deciding confidence bands.
k. Iterations: the number of iterations performed in the last fitting operation.
l. Range1: beginning index of data range used in fitting.
m. Range2: ending index of data range used in fitting.
n. Step: incremental step size used when only a subset of data points were used in the fitting process (Ex.
Step =4 means every fourth data point was used).
o. DataPoints: number of data points considered in the fitting process.
p. DOF: no. of degrees of freedom = No. of data points considered - no. of floating parameters
(parameters that were not fixed).
q. Constr: the number of constraints that the user enters in the General Linear Constraints text box in the
Parameter Constraints dialog box. The Enabled check box has to be selected for the constraints to be
counted.
r. ConstrEff: the number of effective constraints. If you type in constraints on a parameter and then fix
the parameter value (clear the Vary? check box in the Fitting Session dialog box), those constraints will not
be counted.
The Var-Cov Matrix Button
Click this button to create a separate window containing the variance-covariance matrix. Type the desired
window name in the associated text box.
When you click n Iter in the Fit Session dialog box, this causes the fitter to try to perform, at most, n LM
iterations of reduced chi^2. If the relative change of the value of reduced chi^2 between two successive
iterations is less than the value in the Tolerance text box, less than n iterations are performed. If you want
the fitter to perform still more iterations, click on either the n Iter or the 1 Iter button in the Fitting Session
dialog box. The n value is specified in the Max. Number of Iterations text box (see below).
The Max. Number of Iterations Drop-down List
Specify the value for the maximum number of iterations performed when the n Iter button is clicked on in
the Fitting Session dialog box.
The Derivative Delta Group
This group determines how the fitter will compute the partial derivatives with respect to parameters for
user-defined functions during the iterative procedure. The Derivative Delta group is unavailable for builtin functions as Origins curve fitter uses analytical expressions. (Note: You can define a user-defined
function with partial derivatives.)
For the user-defined functions, the derivative with respect to the parameter, p1 , is computed as (for
simplicity, written for a function which has one independent variable):
) (
Leave the check box selected when there are no associated error bars with the data (which is the default and only - option). In this case, the error on the fit parameters is calculated as SQRT(covii).
Leave the check box cleared when the data has associated error bars and a weighting method has been
chosen by you. This is the default, and recommended setting for this check box. In this case, the error on
the fit parameters is calculated as SQRT(covii).
When the data has associated error bars and a weighting method has been chosen by you, you have the
option to select the check box, thereby multiplying the reported error on the fit parameters by the square
root of the reduced chi-squared. In this case, the error on the fit parameters is calculated as
SQRT(covii*(Chi^2/DOF)).The Dependent Var. List Box
If you selected the Arbitrary data set method from the Weighting Method drop-down list, highlight a
dependent variable in this list box. Click on the desired data set name in the Available Datasets list box.
The Available Datasets List Box
Click on the data set name in this list box after selecting the dependent variable in the Dependent Var. list
box (for Arbitrary data set weighting method only).
y = A exp ( x x0 ) / t
] the values of
t 01
. may remedy the
a<b<c;
a/3<9
If there is more than one constraint, separate constraints by a semicolon.
To change lines, press CTRL+ENTER.
The following constraints are invalid as they are nonlinear:
a^2>c;
a*b>3;
1/b>c+2;
sin(a)<c
Five relational operators are supported: =, <, <=, >, and >=. The curve fitter treats < and <= the same.
Likewise > and => are treated the same (this is not true for simple constraints, see above).
You can place multiple operators in a single sentence, such as:
4<a<b<6
which is equivalent to:
4<a; a<b; b<6
Coefficients need not be numeric constants. However, they must evaluate to valid numbers. For example,
if the function has two parameters, P1 and P2, you can use a linear constraint such as P1+qw*P2 assuming
that you have previously given qw a numeric value.
Temporarily disable constraints by clearing (unchecking) the Enabled check box. Constraints take effect
only if the Enabled check box is selected.
Simulation of Data
Select Action:Simulate to open the Simulate Curves dialog box. Features provided in this dialog box are
useful when you are uncertain about the initial values of parameters for fitting. You can plot the
theoretical function for any parameter values in order to compare the curve with the data. This enables you
to get an understanding of which parameter values produce curves that look like the data. This is
important because reasonably good starting parameter values are in most cases a precondition for the
success of the fitting.
After Fitting
Select Scripts:After Fit to open the After Fitting dialog box. Edit this dialog box to define what you want
Origins nonlinear curve fitter to do when ending a fitting session.
Note: You cannot enter Origin C routines in this dialog box - only LabTalk is allowed. However, you can
compile an Origin C function in Code Builder and then call that function using LabTalk. For more
information on Origin C, see the Programming Guide Help file.
Before Fitting
Select Scripts:Before Fit to open the Before Fitting dialog box. Edit this dialog box to define what you
want Origins nonlinear curve fitter to do when starting a fitting session.
Note: You cannot enter Origin C routines in this dialog box - only LabTalk is allowed. However, you can
compile an Origin C function in Code Builder and then call that function using LabTalk. For more
information on Origin C, see the Programming Guide Help file.
Type a LabTalk script in the Scripts to Execute Before Fitting text box for execution when entering a
fitting session. The script in this text box will execute before any scripts in the Initializations dialog box.
However, you must select the Enabled check box for the script to execute.
Upgrade Note: If the version you are upgrading includes a user-defined fitting function with LabTalk
script defined in the pre-7 Initializations dialog box of the NLSF, then this script will be accessible from
this dialog box (Scripts:Before Fit) in the version 7 NLSF.
Parameter Sharing list box. The meaning of parameter sharing (here) is the analogous to the same feature
when fitting multiple data sets.
The Generate Peak Curves During Each Iteration Check Box
Select this check box to display the peak curves for each replica after every iteration.
The Peaks with Baseline
Select this check box if you want each peak curve to be plotted from the common vertical offset.
Fitting Strategies
Do I need NLSF?
Before even starting Origins nonlinear least squares fitter (NLSF), you must determine if you actually
need it. If you want to fit a function, such as:
y = p1 sin( x ) + p2 x
you may be tempted to use NLSF since the function is obviously nonlinear. However, Origins NLSF is
primarily intended for use with functions which depend nonlinearly on at least one of its parameters.
Since the above function is linear in the parameters, you may be better off trying (multiple) linear
regression, which is also supplied with Origin.
Parameter Initialization
An indispensable part of any fitting procedure is a good choice of initial parameter values. The NLSF
provides automatic parameter initialization routines for all of the built-in functions. The parameter
initialization routine for the selected fitting function can be reviewed in the Parameter Initializations dialog
box of the NLSF (Scripts:Parameter Initialization). These routines use the selected dependent and
independent data sets to determine appropriate initial parameter values for the selected fitting function.
The parameter initialization routine for a selected function is automatically run when you activate the
Fitting Session dialog box of the NLSF (Action:Fit). When this dialog box is activated, the Value text
boxes display initial values and the graph displays a first guess fit curve in addition to your data. You can
also manually run the parameter initialization routine by 1) activating the NLSF Parameter Initializations
dialog box, 2) clicking the Check button to compile the initialization routine, and 3) clicking the Execute
button to run the initialization routine. After clicking the Execute button, the Init. Value text boxes should
display initial parameter values.
You can also check and improve initial parameter values using the Simulate Curves dialog box of the
NLSF (Action:Simulate). Use this dialog box to plot your theoretical function for any choice of
parameters. Thus, you can easily compare your data with the theoretical function for any choice of
parameter values. When you find a set of parameter values that generates the curve which closely
resembles the data, start the iterative procedure from those values.
determined. This usually happens when the data are available only in a limited interval of the independent
variable(s). For example, if you are fitting a nonmonotonous function such as Gaussian to the data which
are monotonous, the NLSF will have a difficult time determining the position of the center, or the width of
the peak, since the data obviously describe only one side of the Gaussian peak.
Using Constraints
When trying to reach the reduced chi^2 minimum, the Levenberg-Marquardt method carefully chooses the
path in the parameter space which should lead to the minimum. However, there are situations when good
initial parameter values are hard to find and a small departure can cause the fitter to wander away from the
minimum without being able to come back. To prevent that, you may impose linear constraints on the
parameters. For example, if you believe that the reduced chi^2 minimum for a particular case of Gaussian
fit corresponds to the Gaussian width being greater than 0.1, you can prevent the fitter from trying too
small values of the width w by imposing a constraint w>0.1. Since too small values of the width can easily
cause an arithmetic underflow, you may improve the stability of the iterative procedure.