0% found this document useful (0 votes)
110 views

Fitting A Straight Line To A Set of Data: C MX y

(1) The document describes how to fit a straight line to a set of experimental data using the least squares fitting method. (2) This involves determining the slope (m) and intercept (c) of the line by minimizing the sum of the squares of the differences between the actual (y) and fitted (yfit) values. (3) An example is provided to demonstrate fitting a straight line to a set of (x, y) data points and comparing the actual versus fitted values.

Uploaded by

Kushagra Gupta
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)
110 views

Fitting A Straight Line To A Set of Data: C MX y

(1) The document describes how to fit a straight line to a set of experimental data using the least squares fitting method. (2) This involves determining the slope (m) and intercept (c) of the line by minimizing the sum of the squares of the differences between the actual (y) and fitted (yfit) values. (3) An example is provided to demonstrate fitting a straight line to a set of (x, y) data points and comparing the actual versus fitted values.

Uploaded by

Kushagra Gupta
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
You are on page 1/ 1

Fitting a Straight Line to a Set of Data

In some of the experiments, a straight line is to be fitted to the experimental data. This can be done using the Least
Square Fitting Method. The method can be used to fit any polynomial, but you would require it only for fitting a
straight line. In the following the method for this purpose is described.
Let ( xi , y i ; i = 1,2, K N ) be the given set of data from a measurement. You are required to fit a straight line to this
data. The best straight line, according to the least square method, can be fitted as follows.
Let the equation of the straight line to be fitted be written as
y = mx + c
where the slope m and the intercept c are to be determined from the given data. This is done using the least square
method which gives the following working formulae:

AC − DN C − mA
m= and c=
A 2 − NB N
N N N N
where A = ∑ xi B = ∑ xi2 C = ∑ yi D = ∑ xi yi
i =1 i =1 i =1 i =1

Example: Fit a straight line to the following data:


x 0 2 5 7
y -1 5 12 20

x x2 y xy
0 0 -1 0
2 4 5 10
5 25 12 60
7 49 20 140
Sum= 14 78 36 210
A B C D

AC − DN 14 X 36 − 210 X 4 − 336 84
m= = = = = 2.8966
A 2 − NB 14 X 14 − 4 X 78 − 116 29

C − mA 36 − 14 X 336 / 116 36 X 116 − 14 X 336 − 33


c= = = = = −1.1379
N 4 4 X 116 29

Thus the equation of the straight line is: y = (84 x − 33) / 29


y
A comparison of the given data and the fitted line:
x 0 2 5 7
y -1 5 12 20
x
y fit -1.138 4.655 13.35 19.18

The straight line actually does not pass through any of the given points yet this the best fit line (please see the
figure). In this case, the sum of the square of errors is minimum, i.e. ∑(y − y fit ) 2 , is minimum. Thus, it is not
required that the straight line passes through any of the points for it to be the best fit line.

You might also like