This tutorial will describe how to use the Curve Fitting Tool to fit a simple linear model to some scientific data. The default data used in this tool were taken from Table 6-2 in Phillip R. Bevington's book Data Reduction and Error Analysis for the Physical Sciences. These data are from a radioactive decay experiment in which the y-axis data represent the logarithm of the number of counts read by the detector and the x-axis data represent the time that has passed. (Note that Bevington's book takes the y data to be the number of counts, but this would not be a proper exponential decay law! We instead consider the y-axis data to be the natural logarithm of the number of counts.) Throughout the tool there are blue links which open help documents to aid you while you use this tool.
Upload Data
If you have not already done so, launch the Curve Fitting Tool. In the beginning panel, "Upload Data", you have the choice of uploading your own data, as long as they are in XML (eXtensible Markup Language) form, or use the default data provided. For this tutorial you will want to use the default data, which is Bevington's decay data. Please click on "Use Default Data."
Now that the default data are loaded the "View Data" and "Input Parameters" panels are both unfrozen. After the default data have been uploaded, a success paragraph will appear acknowledging that the default data are now ready to be used. Now click the "Next" button located in the bottom right hand corner of the panel in order to proceed to the "View Data" panel. Alternatively, you may click on the red "View Data" link in the task list.
View Data
In order to help choose what mathematical expression is best to use for your fit, you can view your data in an HTML table or in an IDL plot form. To view the data in an HTML table, click on the "View Data" button.
The result looks like this:
If you want to view your data in the form of an IDL plot, click on the "Plot Data" button. If you want you can change the axis type of both the x and y-axes to linear or logarithmic scale and change the range of both axes.
The result looks like this:
Once you have finished viewing your data, click the "Next" button to go to the "Input Parameters" panel.
Input Parameters
Input your fitting expression into the designated text input field. For this tutorial you want to use a linear fit which is the default fit, so leave this text field unchanged. The fitting expression uses the dependent variable y and the independent variable x. The fitting parameters are expressed in this syntax: P[0], P[1], P[2],...,P[n], where n is the number of fitting parameters. There can be up to 10 fitting parameters in your expression. Please click on the "syntax examples" help-link to see examples of simple allowable expressions.
Choose the number of fitting parameters you will use in your expression. This number should be the same as the number of fitting parameters in the expression in the text field. If you enter too many or too few parameters, you are likely to obtain an erroneous solution. Since the default is a linear fit, there are two fitting parameters, which is the default number of fitting parameters.
Put your guesses for the fitting parameters in each of the designated text fields. These guesses will give the fitting routine somewhere to to begin, but can typically be far away from the actual values of the calculated fitting parameters. If you are unsure of your initial guesses, please leave those parameters at their default (zero) values.
Hit the "Fit Curve" button which will run the IDL fit:
After running the fit, the following window will appear displaying your fitting parameters along with their one-sigma errors and chi-square. It will also display the confidence level of the fit.
Notice that P[0] is the slope of the line and that P[1] is the y-intercept. A success paragraph will appear at the bottom of the panel. Now click the "Next" button at the bottom of the panel to move on to the "View Fit" Panel.
View Fit
To view an IDL plot of the fit, click the "View Fit" button.
Here is the result:
The solid line is the fit to the data.
Challenge
Can you recover the decay rate of radioactive particles from your calculated fitting parameters? Can you experiment with different expressions to get a better fit? For example, suppose the y-axis data really are counts, not logarithms of the counts. How does an exponential fit, P[0]*exp(P[1]*X), compare to the linear fit? Compare the χ2 and the confidence level for the two fits.