7.1 Fitting a Gaussian function to data. A Gaussian function has the form
f (t)= ae-(t-)2/2
Here t e R is the independent variable, and a e R e R. and o e R are parameters that affect its shape. The parameter a is called the amplitude of the Gaussian, is called its center, and o is called the spread or width. We can always take o > 0. For convenience we define p E R3 as the vector of the parameters, i.e., p = [a o]T. We are given a set of data,
ti,...,tN,
y1,...yN
and our goal is to fit a Gaussian function to the data. We will measure the quality of the fit by the root-mean-square (RMS) fitting error, given by
N
/*
E
vD(f(ti)
Note that E is a function of the parameters a, , , i.e., p. Your job is to choose these parameters to minimize E. You'll use the Gauss-Newton method.
(a) Work out the details of the Gauss-Newton method for this fitting problem. Explicitly describe the Gauss-Newton steps, including the matrices and vectors that come up.
parameters, i.e.,
p(k+1) =p(k)+p(k)
(Here k denotes the kth iteration.)
(b) Get the data t, y (and N) from the file gauss_f it_data.m, available on the class website. Implement the Gauss-Newton (as outlined in part (a) above). You'll need an initial guess for the parameters. You can visually estimate them (giving a short justification). or estimate them by any other method (but you must explain your method). Plot the RMS error E as a function of the iteration number. (You should plot enough iterations to convince yourself that the algorithm has nearly converged.) Plot the final Gaussian function obtained along with the data on the same plot. Repeat for another reasonable, but different initial guess for the parameters. Repeat for another set of parameters that is not reasonable, i.e., not a good guess for the parameters. (It's possible, of course. that the Gauss-Newton algorithm doesn't converge, or fails at some step; if this occurs. say so.) Briefly comment on the results you obtain in the three cases.