0% found this document useful (0 votes)
69 views1 page

Least Squares Fitting of A Straight Line (LSFASL)

1. The document discusses finding the "best" straight line fit to experimental data points that each have an associated uncertainty. 2. It explains that the best fitting line is determined using least-squares fitting, which minimizes the sum of the squares of the vertical deviations (residuals) between each data point and the fitted line. 3. Weighted least-squares fitting takes into account the different uncertainties of each data point, while unweighted fitting treats them all equally. The weighted fit will preferentially fit points with smaller uncertainties.

Uploaded by

astrid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views1 page

Least Squares Fitting of A Straight Line (LSFASL)

1. The document discusses finding the "best" straight line fit to experimental data points that each have an associated uncertainty. 2. It explains that the best fitting line is determined using least-squares fitting, which minimizes the sum of the squares of the vertical deviations (residuals) between each data point and the fitted line. 3. Weighted least-squares fitting takes into account the different uncertainties of each data point, while unweighted fitting treats them all equally. The weighted fit will preferentially fit points with smaller uncertainties.

Uploaded by

astrid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Least-Squares Fitting of a Straight Line

Experiments typically require the establishment of some relationship y 54


Weighted and unweighted fits to the same experimental data are
between physical parameters – for example, the period of a 53
Mass of Copper Electrode Versus Time Showing
Weighted and Unweighted Fits shown in Figure 2. Note that the weighted fit preferentially fits the
pendulum and its length. All of the experiments in the Physics 2B 52
data with the smaller uncertainties at the expense of the data point at
yio
laboratory require the fitting of a straight line to experimental data, 51
t=300s which has the largest uncertainty.

Mass (g)
Dyi
from which the physical quantity of interest, and its uncertainty, can yic 50
Unweighted Fit

The Expected Value of c2


Weighted Fit

be determined. 49

48

But given a series of linear data points, each with an uncertainty, how 47 For N data points fitted by a straight line having 2 adjustable
0 50 100 150 200 250 300 350

parameters (m and c), the expected value of c is N-2. This is also


2
does one determine the “best” straight line through the set of data? xi x
Time (s)

The best fitting straight line is clearly that which can be drawn known as the number of degrees of freedom. If c is larger or smaller
2
Figure 1: x-y graph showing the residual Dyi. Figure 2:Least-squares fit to data showing both
passing through, or close to, all the data points. But: weighted and unweighted fits. than this then this indicates that something is wrong with the
assumptions that you have made.
! no two people will draw the same “best” line through a given data
15.8
set Micrometer reading versus N x lambda/2
0.005
Residual versus N x lambda/2 · If c2 >N-2 then the model is not capable of representing the data to
15.7 (gradient is (–) the gear ratio)
! if the uncertainty on each data point is different, how do we take 15.6
0.003
the accuracy suggested by the error bars. Thus, the error bars are too

Micrometer reading (mm)


this into account in determining the “best” straight line? 15.5 small for the scatter of the data.

Residual (mm)
0.001

! finding the uncertainties in the gradient and y-axis intercept of the 15.4

graph is cumbersome, and tends to overestimate their values 15.3


-0.001

· If c2 <N-2 , then the errors have been overestimated, i.e. the fit to
15.2
-0.003
the data is too good, and the error bars are too large relative to the
To avoid these problems we can give a mathematical statement of 15.1

scatter of the data.


15 -0.005
what the “best fitting” straight line means, and then use a computer to 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16
N x lambda/2 (mm) N x lambda/2 (mm)
determine it for us.
The value of c can be estimated from a plot of the residuals after the
2
Figure 3: (Left) Linear LS fit to data from the Michelson interferometer experiment. The fit is excellent, and
Chi-Squared: Figure 1 shows an x-y graph with a line passing close a plot of the residuals (Right) reveals no systematic deviations, but suggests that the uncertainties on each least-squares fit.
data point have been slightly overestimated.
to the data points. For each individual value of x, labeled xi, there are
two values of y: yio refers to the observed value, that is, the one · If c2 » N-2, then ~2/3rds of the data should lie within ±1s of the
0.006 3.00E-05
zero.
measured in the experiment, and yic refers to the calculated value of y Micrometer reading vs n x (lambda^2)/2 for Na doublet Residual vs n x (lambda^2)/2 for sodium doublet
0.005
2.50E-05
· If c2 > N-2 then <2/3rds of the data lie within ± 1s of the zero.
found using the equation of a straight line
micromter reading/gearing (m)

2.00E-05

0.004 · If c2 < N-2 then >2/3rds of the data lie within ± 1s of the zero.
yic = mxi + c
1.50E-05

Residual (m)
0.003 1.00E-05

The difference between the observed and calculated y-value of each 0.002
5.00E-06 Figure 3 shows a linear fit to data obtained from a Michelson
data point is called the residual and is given by 0.00E+00 interferometer experiment. The fit to the data is excellent, and a plot
of the residuals shows that all the data points are within ±1s of the
0.001
-5.00E-06

Dyi = yio - yic 0


0 5E-13 1E-12 1.5E-12 2E-12 2.5E-12
-1.00E-05
0 5E-13 1E-12 1.5E-12 2E-12 2.5E-12
best-fitting straight line, suggesting that the uncertainties in the
micrometer readings of ±0.002mm have been overestimated. We
n x lambda/2 (m) n x (lambda^2)/2 (m)

We clearly want of straight line to have small values of Dyi for each
would therefore expect the value of c to be smaller than 11-2=9.
2
data point. And we state that the best fitting straight line will be the Figure 4: (Left) The linear LS fit to this data from the Michelson interferometer experiment looks excellent,
one where the sum of the squares of the residuals (squared so that but a plot of the residuals (right) from the fit shows a clear systematic deviation from a straight line. Calculation gives a value of c = 3.1.
2

each has a positive contribution to the sum) is smallest. If each data


point has an uncertainty in its y-coordinate of si, then we can define a Weighted and Unweighted Fits Figure 4 shows a linear fit to further data obtained from the same
quantity c2 (chi-squared) as: experiment. Although the linear fit to the data looks excellent, a plot
In an unweighted LS fit we assume that the uncertainty on each data point is the of the residuals shows a serious systematic misfit. We would
2 2 same, and all data points are then treated equally. This is the type of fit therefore expect c2 to be greater than 13-2=11. Calculation gives c2=
i= N é ( y - y ) ù i = N é ( y - ( mx + c ) ù
c 2 = å ê io performed by the standard LINEST function in Excel. 244.
ú = å ê
ic io i
ú
i =1 ë si û i =1 ë si û
In a weighted LS fit, we assume that the uncertainties are not the same and This final example demonstrates the invaluable information that is
Where the sum is over the N data points. weight each data point separately. Data points with small uncertainties are then only visible in a plot of the residuals.
fitted at the expense of those with larger uncertainties. This is the type of fit
Key Point: The best fitting straight line is the one which gives the performed in Excel by the LSFIT function. This is a non-standard addition to
Excel, and was developed in the Dept of Physics at the University of Texas,
minimum value of c2.

You might also like