1. Home
  2. TechGraph User Manual
  3. References
  4. Curve Fitter

Curve Fitter

Curve Fitter Button Icon with Dropdown Options

The Curve Fitter uses statistical methods to determine the “best” equation which fits a set of observations. Both linear and nonlinear algorithms are employed to describe a statistical relationship (equation) between graph series. The Curve Fitter can fit 2-dimensional (X,Y) data.  There are three modes available: linear, nonlinear, and user-defined of the form y=f(x).

The set of experimental observations can often be characterized by fitting the data to a model dependent upon unknown adjustable coefficients. The model can be a straight line, or perhaps an nth order polynomial, where its coefficients serve simply to represent the discrete data in a continuous fashion for the purpose of interpolation. On the other hand, the function’s coefficients may have some theoretical relationship to a physical, biochemical or physiological process. For example, the maximum physiological effect of a drug in a sigmoidal response, the rate coefficient in a kinetic equation describing a chemical reaction, or the rate of growth in a biological phenomenon as described by an exponential curve. 

Linear Curve Fit 

Linear Curve Fit (a) is an intrinsically linear function to the data. This method applies Linear Least Squares regression analysis – a fast, single-step process – to determine the relationship between the two variables x and y. This method chooses coefficients for the function which will minimize the sum of the squares of the differences between the observed y values and the predicted y values.


An equation of the form:  y = a0 + a1x + a2x2 …  +anxn, is linear with respect to the coefficients {a0, a1, a2, …, an}, is used to obtain a linear probabilistic relationship and measure the extent to which the two variables are related. The simplest case is a straight line fit described by y = a0 + a1x.

There are four Group Types (b): Linear, Exponential, Power and Polynomial functions. They use transformations on the x and/or y variables to linearize the data, allowing a straight line relationship to be fitted. Linear least squares regression, utilizing the Gauss-Jordan method for matrix inversion, is then used to determine the coefficients from the transformed data.

In linear curve fitting using Gauss-Jordan, the number of data points must be greater than the number of unknown coefficients. Singularities of a function are removed from the fitting process. Logarithmic and square root transformations on the x and/or y variables require their values to be greater than zero, or no fit is performed for the particular function. 

The linear curve fit option will calculate the best fit for your data from all 100 built-in Linear Functions (c): Linear (40 functions), Exponential (10 functions), Power (25 functions), Polynomial (25 functions). Check the ID box (a) for any number of functions that you think might fit your data.

Once a curve fitting is successful, a Report and Save Tab will become active. Please refer to Appendix C for details about the Report Tab. 

The Save (a) tab menu is shown below.

In the Selection field (b) there are five fit statistics that can be saved and displayed on the graph.

Y Predict Equation
This copies the equation for the fitted function to the Equation field in the Edit Chart → Curves and Error Bars menu, in the graph series indicated by the Destination Col (d).

Predict Values
This option saves the function evaluation for each X,Y pair. The Y values will be saved in the Destination Col. For example, if “B” was written in Destination Col (d), then the Y values will be saved in column B.

Residuals
This option saves the residual (the difference between the Y Predict value and the Y Data value) for each data point. Note that when a linear approximating function with transformations on the response (Y Data) has been performed, the residuals are expressed in the original data’s units.

Confidence Interval
The upper and lower limits of the Confidence Interval at each data point are saved. This creates two new columns of data in the Data Table, starting with the column specified in the Destination Col (d) field. The Confidence Interval is calculated at the Level chosen in the Level field (c). The default Level is 95%.

Prediction Interval
This data is saved in the same way as the Confidence Interval.

The Destination Col field (d) is where the statistics and fit equation are stored.

Example 1:

The chart below shows a set of data that looks generally linear. So, a good starting point for a curve fit would be to choose a few of the built-in linear functions. The actual data is also shown. Be sure to select “Scatter” as the Graph Type and “Number” as the Data Type.

Hint: Refer to X Data Type to change the graph type and X Data Type.

  1. In the Selection tab of the Linear Curve Fit menu, check Linear Functions 1, 2, and 3 (a).
  1. Enter “X” in X Data Col (b), “A” in Y Data Col (c), “1” in Start Row (d), and “8” in End Row (e), and then click Calculate (f). The curve fit was calculated and the Best Fit: Function 3 Coef of Det = 0.980670 (g) is displayed at the bottom. Therefore, Function 3 y=a0+a1*sqrt(x) was the best fit of the three functions chosen. A Coefficient of Determinant of 1.0 is a perfect fit to the data. Additional Fit Statistics were also generated by the calculation.  

  1. Next, click the Save (a) tab and the Linear Curve Fit menu shown below appears. The Report and Save tabs only become active after a successful fitting. Using Save, you can store the fit statistics in the Data Table for further analysis, transfer the fitted equation to the Edit Chart → Curves and Error Bars Series Settings menu. Choose “Y Predict Equation” (b), enter “A” into Destination Col (c) and click Save (d).
  2. Next, click on the Report (a) tab. The fit statistical results from your calculation will be shown here in tabular format. The Download (b) button allows you to save the results as a CSV file in your local drive.  You have a choice to download either the statistical portion or the data portion as CSV file to be read by another application.

The Copy button (c) will copy the results to the clipboard to be pasted to another application. The Print button (d) will print the results to your local printer.

The Confidence Interval option (e) will allow one to set the CIF (LL & UP) values in the report.

  1. Switch to the Edit Chart tab. The chart will be displayed with the equation line drawing with the equation and legend displayed on the chart.

Example 2:

The chart below shows a set of data that looks generally exponential. So, a good starting point for a curve fit would be to choose a few of the built-in exponential functions. The actual data is also shown. Be sure to select “Combo” as the Graph Type and “Number” as the Data Type.

Hint: Refer to X Data Type to change the graph type and X Data Type.

  1. Following a similar process as in the previous example, check Exponential Functions 42 through 49 (a), enter ”X” in X Data Col, “A” in Y Data Col, “1” in Start Row , and “8” in End Row, and then click Calculate. The curve fit was calculated and the Best Fit: Function 43 Coef of Det = 0.982816 is displayed at the bottom. Therefore, Function 43: ln(y)=a0+a1*sqrt(x) was the best fit of the nine functions chosen. 

  1. Next, click the Save tab (a) and select “Y Predict Equation” (b), enter “A” into Destination Col (c), and click Save (d).
  1. In the Selection field, select “Confidence Interval” (e), Level “95%” (f), and enter “B” for Destination Col (g). Click Save. The confidence values of X and Y will be stored in columns B and C, respectively.
  1. The Confidence Values are stored in Columns B and C as shown in the Data Table below. They are plotted on the chart in blue above and below the black equation curve fit line.

Note: Refer to Settings to set Graph Series A to “Scatter” and Graph Series B and C to “Line”.

Nonlinear Curve Fit

Nonlinear curve fits a nonlinear function with regard to the unknown coefficients, for example: y = a0 + a1*exp (a2 * x) or z = a0 + a1*x – sin (y/a2)

As with linear curve fitting, the objective remains to relate variables in a statistical relationship. The Levenberg-Marquardt algorithm is utilized in an unconstrained optimization approach to estimate the coefficients of the equation. This is an iterative process which begins with initial estimates of the unknown coefficients of the fitting function and continues until the best coefficients are found. Like the Linear method, this algorithm returns the coefficients which minimize the sum of the squared deviations, or Chi-squared value.

In simple terms, the Curve Fitter estimates a starting point on a surface whose height is represented by the Chi-squared value, and steps along in the downhill direction until the lowest point on the surface is encountered.

The nonlinear option will determine the best fit from your choice of 15 built-in parametric functions plus one user-defined equation. These parametric nonlinear equations are divided into four families: Standard, Waveform, Peak, and Transition. For more detail on the 15 resident parametric functions, please refer to Appendix A

You may also include the “User-Defined” selection as one of your functions. See the section on User-Defined Curve Fit below.

Example:

The chart below shows a set of data that looks generally Transitional. So, a good starting point for a curve fit would be to choose a few of the Transitional built-in functions. The actual data is also shown. Be sure to select “Scatter” as the Graph Type and “Number” as the Data Type.

Hint: Refer to X Data Type to change the graph type and X Data Type.

  1. Following a similar process as in the previous example, check Functions 4,7,8,and 9, enter “X” in X Data Col, “A” in Y Data Col, “1” in Start Row, and “11” in End Row, and then click Calculate. The curve fit was calculated and the Best Fit: Sigmoidal Function 9 Coef of Det = 0.998846 is displayed at the bottom. Therefore, the Sigmoidal Function 9: y=a0+a1/(1+exp(-(x-a2)/a3)) was the best fit of the four functions chosen.  
  1. Click the Save tab and select “Y Predict Equation”, Destination Col “A”, and click Save. The resulting chart is shown below.

User-Defined Curve Fit

You can specify a function of the form y=f(x) with up to eight unknown coefficients. You can enter your own function, or select a pre–defined nonlinear function and edit it to your specifications.  

The unknown coefficients are entered as a0 through a7 and must be sequential starting with a0.  For example, the equation of a straight line (y = mx + c) is entered as: a0*x + a1. If you want to fit a straight line and force it to pass through the origin (0,0) you would enter a user-defined function as: a0*x

You must specify reasonably approximate starting values for each unknown coefficient in the function. See Hints for Starting Coefficients in Appendix B for information about starting values for the nonlinear functions.

Example:

Looking at the data on the chart below, it looks like a decaying waveform. From past experience you might know the equation: Y=a*sin(x)/x is a reasonable equation to match the data.

  1. In the User-Defined tab (b) you will enter in the equation: a0*sin(x)/x in the Fit Equation field (d), with a0 being the coefficient you are looking to calculate. In the a0 field (a), enter “5” as a starting point, and in the Coefficient Count field (c), enter “1”. Click Save. The equation will be saved as the User-Defined function 1 in the Built-In tab menu. Follow the same method for Built-in curve fit functions listed above. 

The resulting curve fit and equation are shown below with a Coef of Det = 0.970746.

How can we help?