Handout Fitting models to data, through the section“Outliers”.Fit to data with unknown uncertainties.
Completing all of the non-starred activities will count as A-level work. To receive credit, these activities must be checked off in class or office hours within three weeks. (by Thurs 3/28, skipping over Spring Break so really four weeks this time.)
Fit the data in the file txt to poly- nomials of various orders, and use the results to decide what model (whatorder polynomial) is justified for fitting this data. For this pur- pose, if you like you can simply copy code from the section “Nonlinear least-squares fitting” in the Fitting models to data handout, or you can use your own code. In any case, be sure to include the parts that print out the parameters with their uncertainties, and χ2.
The file txt has only two columns (x and y, but not yerr). Make some slight modifications to the program to deal with this kind of data with no uncertainties given. and again fit the data to polynomials of various ordersand decide what order polynomial is justified as a model for the data.Computational Here are the modifications you need to make to the program:
Redo the 5-parameter (gaus- sian + linear background) fit to the data in txt that is in the Fitting models to data handout (you can cut and paste the program from the handout). Then, change the parameter guesses to all ones and see what happens. This was OK for a linear model like the poly-nomial(which has only one minimum in χ2) but it doesn’t work here. Explore a bit how much the guesses can be changed while still success- fully finding the global minimum in χ2.
Fit the data in peak4.txt using one additional parameter, so the model is a gaussian plus a quadratic background. Determine whether or not using this additional parameter is justified.
The data in the file txt is oscillatory. First simply read the data and plot it. Based on the plot, decide on a likely model for the data. Write a program to fit your model to the data.
(You may want to start by googling the nameof this ) The following two functions both describe peaks of height A and width w centered at x0, with constant additive back- ground B:
1The first function fg(x) is the by-now familiar Gaussian peak. The second function fA(x) is called a Lorentzian peak – it occurs naturally in resonant phenomena such as optical transitions of atoms.Computational
Fit the data in the two files gl1.txt and gl2.txt to see which type of peak best describes each data set. Note: Since these data sets do not have specified uncertainties, you should not expect to find the reported χ2 = 1. Nevertheless, is does make sense to compare χ2 between the two types of fit to help determine which function fits a data set better.