For each of the following exercises create the specified files with your answer(s). Submit your homework using the course submit utility.
y(w) = a1 + a2 * exp[-(w - a3)2/(2*a42))
The data could represent the result of the measurement of an
absorption spectrum. A typical research objective would be to
determine the amplitude a2, frequency a3 and "peak
width" or standard deviation a4.
The program uses the Levenberg-Marquardt (LM) method to fit the data. This methods are described in "Numerical Recipes" in section 15.5. Please read this section to learn more about what the algorithms are doing.
The program source files and Makefile are also found in the directory ~p6730/examples/a07. You are to compile the code and run it.
To run the program spectrum1, use the command
spectrum1You are prompted for the following input values:
The goal of this exercise is to study the sensitivity of the Levenberg-Marquardt method to the choice of input parameters. So try fitting the data in peak1 with the following starting parameters:
Attempt #1
a1 = 0.1
a2 = 2
a3 = 130
a4 = 2
Then run it with the following choice
Attempt #2
a1 = 0.2
a2 = 1
a3 = 175
a4 = 2
Copy your standard output to spectrum1.txt to hand in.
Then answer the following questions in the same file.
y(w) = a1 + a2 * exp[-(w - a3)2/(2*a42))
+ a5 * exp[-(w - a6)2/(2*a72))
To do this rewrite the main program spectrum1.cc. (Call your new
version spectrum2.cc) and the subprogram
peak1.cc (Call it peak2.cc).
In a file spectrum2.txt give the standard output from your fit to two peaks. Follow that with the answers to the following questions:
Now for a little review of our in-class exercise: In the file peak3 you will find a synthetic spectrum generated from two peaks:
amplitude freq width
1 140 8
.6 147 6
If you look at the plot, it looks like one peak, however. We will
pretend we don't know whether there are supposed to be two peaks or
one, so we fit this data using two models listed below. However, to
speed things up, you may use the above information to help extract two
peaks from the data.
Model #1 Two peaks Model #2 One peakInclude the standard output from your two fits in the same answer file spectrum2.txt. Then answer these questions in the same file: