Data Analysis: Least-Squares Curve Fitting
Dr. Erlenmeyer's Example

 

In experimental research one often would like to match a theoretical curve to a set of experimental data by adjusting one or more unknowns. This may be for the purpose of verifying a theory or to measure some unknown parameter. This type of problem arises in many fields, and solution methods have been developed extensively. This document gives a brief introduction to a simple and popular method of curve fitting or data regression, the linear least-squares fit.

As an example, suppose Dr. Erlenmeyer has developed a theory that describes the efficiency of a revolutionary semiconductor laser his lab has invented. Once the current through his device is raised above some threshold, his theory predicts that every milliamp increase in current will increase the output laser power by about a microwatt. In mathematical terms this is expressed as:


P(microwatts) = e * I(milliamps) - Io

To test his theory Dr. Erlenmeyer and his students construct one of the new lasers and take the following data.

Current (milliamps) 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
Laser Power
(microwatts)
0.000 0.000 0.001 0.003 0.018 0.056 0.115 0.201 0.301 0.523 0.563 0.823 0.783 1.233 1.503 1.743 2.003 2.283 2.703 2.923

Now they want to find values for the threshold current Io and the parameter e that will match their data to the theoretical result. A criterion is needed to decide when the optimum fit is achieved. They choose the popular Least-Square Error criterion.
For more details on Least-Square Error fitting, click on the teacher.

Dr. Erlenmeyer's rule happens to be a linear one. In other words, the second set of data should be equal to the first set of data times a number and plus a constant.

Y = aX + b

Or in the case of laser output power versus current,

P = eI -Io

There is a specific version of Least-Square Error that gives a specific formula for fitting a straight line to the data (the Linear Least-Squares fit). Since Dr. Erlenmeyer's rule is a linear one, this should work well. For more details about the Linear Least-Squares Fit, click on the teacher.

Examining the data, Dr. Erlenmeyer concludes that the threshold current must be about 0.3 milliamps. Since the equation relating current to output power only applies to currents above threshold, data below this range must must be thrown out. Using the data from 0.4 milliamps and up, Dr. Erlenmeyer obtains the fit depicted by the curves below. Click on erlen_l.m to see the matlab script Dr. Erlenmeyer used for this calculation.

Although this fit was not bad, there seemed to be a slower rise near threshold and a quicker rise in power at high currents. After reexamining the original theories, Dr. Erlenmeyer's protege, Bertrum Brainsurge, found an aspect of their gain/loss equation that had not been accounted for correctly. Working through two sleepless nights he develops the correct power vs. current formula:


P = e ( I - Io )2

To use the linear least-squares-fit technique for this equation, the square root of this formula is taken:


sqrt(P) = sqrt(e) ( I - Io )

For more details on Linear Least-Squares fitting with nonlinear rules, click on the teacher.


Using the square root of the output laser power converts the rule into a linear one. Fitting a line to this transformed rule produces the final graph. Click on erlen_nl.m to see the matlab script Dr. Erlenmeyer used for this calculation.

This equation provides a much better fit! The sum of the squares of the errors (difference between each piece of actual data and the estimate) went down from ET = 1.361 to 0.02667. That is, the relative error is only one fiftieth of what it was using a straight linear fit. The paper they wrote about their new theory gained them much recognition and also appearances with Jay Leno and Oprah Winfrey.

[ Physics and Astronomy Home Page]  [Northwestern University Home Page]