CyberWit Inc. Logo
 

DataScene
Overview
Feature Matrix
Charting and Plotting
Chart Animation
Data Analysis
Curve Fitting
Real-time Data Monitoring
User Interface
Documentation
Video Tutorials
Graph and Animation Gallery
Series and Graphs
Animations
Series Functions
Math Functions
Support
Purchase
Download
OEM/Integration Solutions

Tutorial 9. Series Functions - Part II

In this tutorial, we will learn how to perform nonlinear curve fit. It is recommended that you read the topic Nonlinear Fit  before continue.

In nonlinear curve fit, if a pre-defined model function (i.e. Exponential, Gaussian, Lorentzian, Polynomial, or Voigt) is selected by the user, DataScene will try to estimate a reasonable set of initial parameters for use in the fit; if a user defined model function is selected, the user will need to supply the initial values of the parameters. We will demonstrate this in the following sections.

Using Pre-defined Model Functions 

Start the DataScene program and create a new data table. Set column formulas "Row" and "Exp[ -0.5 * (Cell("Table1", "Column 1", Row) - 22)^2 / 36 ] + 0.35 * Exp[ - 0.5 * (Cell("Table1", "Column 1", Row) - 39)^2 / 9 ] + Rnd() / 25" for rows 1 to 50 of Column 1 and Column 2, respectively. Plot a Line series, line1, in a graph document, Graph 1, with Column 1 and Column 2 as the Position and Value components, respectively. The series line1 represents two Gaussian peaks with small random noises.

With Graph 1 as the active document, select the Graph: Series Function: Nonlinear Fit menu command. Switch to the Nonlinear Fit tab-page of the Series Function dialog box. Select Gaussian in the Function Type combo-box, and DataScene switches to the Fit Gaussian tab-page. Increment the value in the Number of Peaks spin box to 2 because we have two Gaussian peaks in the source series. Check the Show individual peaks check box to enable DataScene to draw the two fitted Gaussian peaks along with the source and destination series. Move the Initial Position track bar so that the left dotted line in Graph 1 moves to the center of the first peak. Leave the value in the Initial Width spin box unchanged. By now, we have set the initial position and width for the first peak. Increment the value in the Peak Number spin box to 2. Move the Initial Position track bar so that the right dotted line in Graph 1 moves to the center of the second peak. Again, we accept the estimated width in the Initial Width spin box for the second peak.

Fig. 1. Choosing the initial peak position for the second Gaussian peak.

 

Click the Apply button of the Series Function dialog box to perform the fit. After the fit is finished, DataScene automatically prints the fitting information including the fitted parameters in the Messages window. DataScene also automatically switches to the Nonlinear Fit tab-page where the the fitted parameter are displayed in the Parameter List grid. For a simple fit like this, DataScene should be able to converge within the maximum number of iterations - which is by default 30 as shown in the Max. Iterations spin box on the Nonlinear Fit tab-page. If this is not the case, you may need to press the Apply button again to start another fit session using the current parameters. After you finish fitting, close the Series Function dialog box. In addition to the source and destination series, two Line series are created to represent the two fitted Gaussian peaks. You may want to change the colors of the series to make them more visible.

Fig. 2. Two-peak Gaussian fit of the line1 series.

 

Using User Defined Model Functions

Add a new data table, Table2, to the project. Set column formulas "Row" and "Exp[-Cell("Table1", "Column 1", Row) / 20] * Sin[Cell("Table1", "Column 1", Row) / 3] + Rnd() / 10" for rows 1 to 50 of Column 1 and Column 2 of Table2, respectively. Plot a Line series, line1, in a graph document, Graph 2, with Column 1 and Column 2 of Table2 as the Position and Value components, respectively. 

Select the Graph: Series Function: Nonlinear Fit menu command. Switch to the Nonlinear Fit tab-page of the Series Function dialog box. With User Defined selected in the Function Type combo-box, type "y0 + exp(-x/a0) * sin(x/b0)" in the Function text box as the model function for the fit. In the Parameter List grid, enter the three parameters: y0, a0, and b0 in the Name column; enter 0, 1, 1 in the Value column as the initial values of the three parameters, respectively. The variable x in the model function is a built-in variable representing the independent variable. You can verify this by opening the Formula Editor (by clicking the Editor button) and switching to the Variable & Parameters library mode to see the descriptions. Click the Apply button to perform the fit. Although the initial values we provided are far away for the optimized values, the nonlinear fit converged successfully for this simple fit.

Fig. 3. Source line1 series and the fitted destination line2 series in Graph 2.

 

Close the project without saving it.

 

See Also

 

Home | Purchase | Diatomic | Contact | Site Map | About Us
© 2008 – 2011 CyberWit, Inc. All rights reserved.