Physics Department | Center For Optical Technologies | Lehigh University  


Prof. Ivan Biaggio  

Research Group  

Publications  

-Teaching

Contact  












PHY474 - Seminar in Modern Physics

Experimental data and theoretical models. Curve Fitting and its Challenges



About LaTeX

If you are on a Mac (I can't really advise on other platforms), go get TeXShop and TeX Live. (The link takes you to a page where you will find what they call a "smaller distribution". You can just get this smaller distribution, unless you really want to do very very fancy things....

One way to write scientific papers, used to publish in the American Physical Society journals, is RevTeX. However, if you download the stuff above, then it should already contain the latest version of RevTeX.

Example: Download the write-up that I prepared to describe the first case study. The LaTeX/RevTeX file is DispersionFitting.tex. This file uses a figure, which is the pdf file IndexDataPlot.pdf. Once you are ready with your LaTeX software, then put these two files in a new directory, open up DispersionFitting.tex, and run LaTeX on it.
Apart from describing the first case study, it also shows off everything you need to know in order to understand and use LaTeX. Look at how things are done in this write-up, and copy them when you do your own work.

About Curve Fitting

Apart form standard literature that you can look for using the various literature search services, one good way to jump right in is to have a look at the handbooks of fitting software. These tend to have the advantage of being very praxis oriented. If it is possible to skip over the technical stuff relating to software and user interfaces that is often present in these manuals, the rest gives a good insight on the main problems.

Here a few links to such handbooks:

Software for this Seminar

If you have access to a Mac and are not already addicted to a preferred technology, then use pro Fit. There is a free trial version available that should be enough for most of what we will do. In addition, I'll distribute a registration code valid for this seminar. If you have the registration code, download the full package.

pro Fit lets you define your own functions for curve fitting using either a custom version of the venerable Pascal programming language, or using the more fashionable Python. The first is easier to write and explain to people. If you know the second you can do lots of stuff.

First Part

This is the list of topics from which the first presentations will be selected:
  1. Comparing data and models.
    Suggested content:
    A function y=f(x,a1,a2,a3,...) can be used to fit a data set (x,y) by optimum choice of the parameters a1,a2,a3... This should review how one can calculate a number that gives a quantitative measure of the deviation between function and data, which then depends on the values of the parameters a1,a2,a3... This is the quantity that will then be minimized by fitting algorithms. Discuss the role of experimental errors, taking into account different error distributions and experimental errors in multiple dimensions (i.e. what do do if there are errors in x as well as in y)
  2. What is curve fitting?.
    Suggested content:
    Algorithms to minimize chi squared, general overview. Difference between Linear and Nonlinear Curve Fitting. Nonlinear curve fitting: Overview of the most common methods without going into too many details. Steepest descent (gauss-newton) method, LM, others.
  3. The Levenberg Marquardt method.
    Suggested content:
    Explanation of the principles on which the algorithm rests, and of the data structures it uses. Some literature:
    Kenneth Levenberg (1944). "A Method for the Solution of Certain Non-Linear Problems in Least Squares". The Quarterly of Applied Mathematics 2: 164-168. (1944)
    Donald Marquardt (1963). "An Algorithm for Least-Squares Estimation of Nonlinear Parameters". SIAM Journal on Applied Mathematics 11 (2): 431-441. doi:10.1137/0111030.
    Jose Pujol The solution of nonlinear inverse problems and the Levenberg-Marquardt method Geophysics 72, W1 (2007); doi:10.1190/1.2732552
  4. Other fitting algorithms.
    Suggested content:
    Discussion and overview of how the algorithm has been extended to work in more general cases. One example is fitting with errors in the independent variable (see reference below) but there should be others. Investigate the literature, give an overview. P.L. Jolivette, "least-squares fits when there are errors in X," Computer in Physics, Vol. 7, No. 2, 1993.
  5. Interpreting curve fitting results
    Suggested content:
    The result of a curve-fitting operation is not only the set of parameters a1,a2,a3... that leads to the minimum in the chi-squared. Additional information can be provided on how precise the estimation of those parameters can be. Discuss how errors can be obtained for every parameters, the case of parameters being independent from each other or not. Discuss the covariance matrix that is one of the outputs of the Levenberg Marquardt algorithm after a fit. Explain the role of its diagonal elements, and of the off-diagonal ones.
  6. Evaluation of fitting qualty
    Suggested content:
    How to evaluatehow good a fit is. The "Goodness of fit: quantity. How it is influenced by experimental errors. The problem of evaluating confidence intervales for the parameters beyond standard deviations. Monte Carlo methods to get the confidence intervals.
  7. Curve fitting in more than two dimensions
    Suggested content:
    Fitting in multiple dimensions, surfaces, parametric curves (orbits?). Other suggestions are welcome!

Second Part

The topic of the second set of presentations will be decided during the first part of the seminar. Here just a few examples
  1. The Peak Fitting Problem.
    Suggested content:
    Peak Fitting is peculiar because it can concievably use dozens and dozens of parameters and still be a very stable problem. This is because when peaks are well separated from each other the parameter's of each peak are totally independent from the other one, as can be readily seen from the covariance matrix. But in other cases peaks are near, and this changes. The talk should be an overview of the standard peak fitting methods and its main challanges.
    As Part of this presentation consider this data set as a further case study. It shows how a certain photoluminescence spectrum changes depending on light polarization. The columns contain the data for polarization angles from 0 to 90 degrees. Thanks to peak fitting, one can extract the bands that are not polarization dependent and those that are, and identify their position and amplitude.
  2. Determining the best values of the fundamental physical constants, 7/26
    The best values for the fundamental physical constants are identified by a least squares fitting procedure that takes into account all the various measurements that are available and how they depend from each other. This adjustmant is done every four years, and here is the 2006 article. A description of the procedure is also found here, but many more resources can be found. The use of the covariance matrix is described in Appendix F (page 484) of this reference.

Case Studies

Here a list of the case studies that we will experiment with and discuss:
  1. Refractive Index Dispersion
    A description is found in DispersionFitting.tex and IndexDataPlot.pdf if you want to look at the LaTeX source code. Otherwise here is a pdf.
    In addition, here is the data set, as a as a zipped pro Fit file, and as a text file.
    The result of this analysis should be:
    • A discussion of the refractive index model that can be reasonably used to describe the data, and of the appropriate set of parameters.
    • A plot of the temperature dependence of these parameters.
    In addition, look a the information returned by the Levenberg-Marquardt fitting algorithm:
    • Standard deviations of the fitted parameters.
    • Full covariance matrix.
    • Compare the above between the case where you fit the data with three inedependent Sellmeier oscillator and the case where you fit it with two oscillator plus a term proportional to the square of the wavelength.
  2. Transmission of a thin film on a substrate
    A description is found in FilmTransmissionFitting.tex and Tplot.pdf/TPlot2.pdf if you want to look at the LaTeX source code. Otherwise here is a pdf.
    In addition, here are the data sets, as a as a zipped pro Fit files, and as text files: three films, another film.
    The results of this analysis should be:
    • A plot of the refractive index vs. wavelength as can be obtained from this data,including a discussion of the wavelength range over which this result can be trusted, and an indication of the precision with which the index can be known.
    • A plot of the absorption vs. wavelength as can be obtained from this data, over the wavelength interval for which the result can be trusted.
    • The thicknesses of the three films, with an estimation of the precision with which it can be known.
  3. Mystery data
    No lengthy description this time. Here is the data file. The first column is the inverse of the temperature (in K) multiplied by 1000K. The second column is the temperature. The third column is what was measured. You can think of it as a rate. To simplify, assume that the physical process involved here makes this rate exponentially dependent on 1/T, as described by exp(E/(kB T)) where kB is Boltzmann's constant. See if you can determine the energy E, and discuss what the nature of the experimental errors must be in this data set.
    Compare your results for three different approaches
    • Transformation of the data into a liner problem by taking the log of hte y-values, followed by a linear fit.
    • Nonlinear fit using percent errors in the y-values.
    • Nonlinear fit of the y-values vs. T (not 1/T) assuming a constant x-error of 1 degree (and vanishingly small y-errors)
  4. Decay times
    This time we have the measurement of a time dynamics of the photoluminesence emitted by a sample after exitation with what can be effectively considered as a delta function in time. After excitation the signal emitted by the sample decays. Here is the data. First column is time, the next two columns are the signal emitted by the sample in two different conditions. Unfortunately, one of the two conditions leads to a lower signal strength and more noisy data. The questions now are (1) Are the decays exponential? (2) What are the decay time constants [the tau in exp(-t/tau)}? (3) Is any difference in decay time constants between the two data sets significant? After you have answered these questions, conclude by giving the values for the two exponential time constants and the experimental errors with which they are affected.
    Hint: You need to fit this data with an exponential decay with offset, that is a function of the form exp(-t/tau) + c. When you do this,
    • Discuss how the two parameters (tau, c) influence each other.
    • Each data set will deliver a value for the two parameters (tau,c). Discuss the relative position of these two values. Are they "far enough apart"?
    • Again, use the various tools that we discussed: standard deviations, covariance matrix, size of the minimum in the chi-2 landscape.
  5. Chi-squared landscape and fitting behavior
    The idea here is to test the fitting algorithms in your software of choise and determine how they behave. Here is the data set. This data should be fitted by the function f(x,a1,a2) = sqrt( sqr(1+a1*x) + sqr(a2*x)).
    • Plot the chi-squared landscape as a contour plot (a topographical map) in the coordinates (a1,a2). I suggest a range between -1 and 1 for both parameters.
    • Start a fit using various initial values for the two parameters. Try at least the following values for (a1,a2), but you can try more: (0,0), (1,0), (10,0), (0,0.2), (0.0,0.01).
    • Try out (if you can) a couple of different fitting programs, see if they all behave the same. Check the number of iterations they need for every starting value, check if there are any difficulties.
    • Discuss what happens, explain any difference in behavior when using different starting values.
    • Do it yourself: Evaluate by hand the first step in the fitting process using both steepest descent, Gauss-Newton, and the Levenberg-Marquardt method with some value of "lambda", discuss what happens for the different intial values.
    Hint: I've gotten some questions about data and function. They are correct. The function fits the data around (a1,a2) = (-0.5,0.6).

Case Studies - Deliverables

Produce a written report on the four case studies. To do this, go through the case studies and apply what we have learned until now: Analyze the results of the fit including a discussion of errors of the fitted parameters, chi-2 landscape, shallowness of the minimum, covariance matrix. You can send me an intermediary report that I will then post below so that you can all consult what the others did.
After the last two talks, re-visit the case studies one more time while applying the latest that you have learned. In particular the concept of confidence intervals.





Contact | Goto Top of Page  


Lehigh University Center for Optical Technologies