Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

least square method

Le lo bc

Uploaded by

trialocto63
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

least square method

Le lo bc

Uploaded by

trialocto63
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

14. Explain the fitting of a straight line by Least Square Method.

(Important)

Solution : Let us consider, (𝑥𝑖 , 𝑦𝑗 ), 𝑖 = 1,2,3, … … , 𝑛 are the 𝑛 sets of observations


and suppose, the related relation is y = ax + b. Now we have to select 𝑎 and 𝑏 so
that the straight line is the best fit to the data.
The residual at 𝑥 = 𝑥𝑖 is
𝑑𝑖 = 𝑦𝑖 − 𝑓(𝑥𝑖 ) = 𝑦𝑖 − (𝑎𝑥𝑖 + 𝑏), 𝑖 = 1,2,3, … , 𝑛
𝑛 𝑛
2
𝐸 = ∑ 𝑑𝑖 = ∑[𝑦𝑖 − (𝑎𝑥𝑖 + 𝑏)]2
𝑖=1 𝑖=1
By the principle of least squares, E is minimum.
𝜕𝐸 𝜕𝐸
= 0 𝑎𝑛𝑑 =0
𝜕𝑎 𝜕𝑏
i.e., 2 ∑[𝑦𝑖 − (𝑎𝑥𝑖 + 𝑏)] (−𝑥𝑖 ) = 0 𝑎𝑛𝑑 2 ∑[𝑦𝑖 − (𝑎𝑥𝑖 + 𝑏)] (−1) = 0

i.e., ∑𝑛𝑖=1(𝑥𝑖 𝑦𝑖 − 𝑎𝑥𝑖 2 − 𝑏𝑥𝑖 ) = 0 𝑎𝑛𝑑 ∑𝑛𝑖=1(𝑦𝑖 − 𝑎𝑥𝑖 − 𝑏) = 0

i.e., 𝑎 ∑𝑛𝑖=1 𝑥𝑖 2 + 𝑏 ∑𝑛𝑖=1 𝑥𝑖 = ∑𝑛𝑖=1 𝑥𝑖 𝑦𝑖 ………. (1)

and, 𝑎 ∑𝑛𝑖=1 𝑥𝑖 + 𝑛𝑏 = ∑𝑛𝑖=1 𝑦𝑖 ……….. (2)

Since, 𝑥𝑖 , 𝑦𝑗 are known, equations (1) & (2) give two equations in 𝑎 & 𝑏. Solving
for 𝑎 & 𝑏 from (1) & (2) & we obtain the best fit 𝑦 = 𝑎𝑥 + 𝑏.
Important Note:
(A) Equations (1) & (2) are called normal equations.
(B) Removing suffixes 𝑖 from (1) & (2), the normal equations are

𝑎 ∑ 𝑥 + 𝑛𝑏 = ∑ 𝑦 & 𝑎 ∑ 𝑥 2 + 𝑏 ∑ 𝑥 = ∑ 𝑥𝑦

These equations are obtained by taking ∑ 𝑜𝑛 both sides of 𝑦 = 𝑎𝑥 + 𝑏 and by


taking ∑ 𝑜𝑛 both sides after multiplying by 𝑥 on both sides of 𝑦 = 𝑎𝑥 + 𝑏.
𝑥−𝑎 𝑦−𝑏
(C) Transformation like 𝑋 = ,𝑌 = reduce the linear equation 𝑦 = 𝑎𝑥 + 𝑏
ℎ ℎ

to the form Y = AX + B. Hence, a linear fit is another linear fit in both systems of
co-ordinates.
15. By the method of least squares find the straight line to the data given below :

x 5 10 15 20 25
y 16 19 23 26 30

Solution : Let us consider, the straight line is, 𝑦 = 𝑎𝑥 + 𝑏.

The normal equations are :

𝑎 ∑ 𝑥 + 5𝑏 = ∑ 𝑦 …………(1)

𝑎 ∑ 𝑥 2 + 𝑏 ∑ 𝑥 = ∑ 𝑥𝑦 ………….(2)

Now, we have to calculate ∑ 𝑥, ∑ 𝑦, ∑ 𝑥 2 , ∑ 𝑥𝑦 and so we form the following table

𝑥 𝑦 𝑥2 𝑥𝑦
5 16 25 80
10 19 100 190
15 23 225 345
20 26 400 520
25 30 625 750
Total 75 114 1375 1885

The normal equations are : 75a + 5b = 114 ………..(3)

1375a + 75b = 1885 ……(4)

Solving (3) and (4), we get, a = 0.7, b = 12.3

Hence, the best fitting line is y = 0.7𝑥 + 12.3 ………… (P)

By Second Form :
𝑥−𝑎 𝑥−15
Let us consider, 𝑋= = where, 𝑎 = 15 (middle point of the column 𝑥)
ℎ 5

𝑦−𝑏 y−23
𝑌= = where, 𝑏 = 23 (middle point of the column 𝑦)
ℎ 5

Let us take, the line in new variable is : 𝑌 = 𝐴𝑋 + 𝐵


𝑥 𝑦 𝑋 𝑋2 𝑌 𝑋𝑌
5 16 −2 4 −1.4 2.8
10 19 −1 1 −0.8 0.8
15 23 0 0 0 0
20 26 1 1 0.6 0.6
25 30 2 4 1.4 2.8
Total 0 10 −0.2 7

The normal equations are : 𝐴 ∑ 𝑋 + 5𝐵 = ∑ 𝑌 ……….(5)

𝐴 ∑ 𝑋 2 + 𝐵 ∑ 𝑋 = ∑ 𝑋𝑌 ……(6)

Solving (5) and (6), we get, A = 0.7 and B = −0.04

∴ 𝑌 = 0.7𝑋 − 0.04
y−23 𝑥−15
 = 0.7 × − 0.04 = y − 23 = 0.7𝑥 − 10.5 − 0.2
5 5
 y = 0.7𝑥 + 33.3 ………………..…………….(Q)

Thus, the equations (P) and (Q) are same.

16. Fit a straight line to the data given below. Also estimate the value of y at x =2.5

x 0 1 2 3 4
y 1 1.8 3.3 4.5 6.3

Solution : Let us consider, the straight line is, 𝑦 = 𝑎𝑥 + 𝑏.


The normal equations are :
𝑎 ∑ 𝑥 + 5𝑏 = ∑ 𝑦 ……………….(1)
2
𝑎 ∑ 𝑥 + 𝑏 ∑ 𝑥 = ∑ 𝑥𝑦 ……………….(2)

𝑥 𝑦 𝑥2 𝑥𝑦
0 1 0 0
1 1.8 1 1.8
2 3.3 4 6.6
3 4.5 9 13.5
4 6.3 16 25.2
Total 10 16.9 30 47.1
From the above table, the equations can be re-written as

10a + 5b = 16.9 ………………… (3)

30a + 10b = 47.1 …………………(4)

Solving (3) and (4), we get,

a = 1.33, b = 0.72

Hence, the equation will be,

𝑦 = 𝑎𝑥 + 𝑏 = 1.33𝑥 + 0.72

At 𝑥 = 2.5, 𝑦 = 1.33 × 2.5 + 0.72 = 4.045

[ These two problems (Q. Nos. 15 & 16) are very important.]

You might also like