Curve fitting - Brief lecture notes PDF

Title Curve fitting - Brief lecture notes
Course Probability, Statistics And Numerical Methods
Institution APJ Abdul Kalam Technological University
Pages 7
File Size 184 KB
File Type PDF
Total Downloads 39
Total Views 149

Summary

Brief lecture notes...


Description

Discussion 4 & 5 1

CURVE FITTING Let (x1 , y1 ), (x2 , y2 ) ,…, (xn , yn ) be n pairs of observations of related data. The general problem of finding a relation of the form y = f (x) which fits best to the given data is called curve fitting.

1.1 Principle of least squares Let (x1 , y1 ), (x2 , y2 ) ,…, (xn , yn ) be n pairs of observations of related data. Let y = f (x) be the best fit curve . yi is called the observed value y corresponding to x i and f (xi) is called the expected value of y corresponding to xi . yi – f (xi) is called the error or residual for yi .The principle of least squares states that for a best fit curve , the sum of squares of residuals is n

minimum. ie., E   y i  f ( x i )2 is minimum . i 1

1.2

Fitting a straight line

Let y = ax + b be a best fit straight line to the n pairs of observations (x1 , y1 ), (x2 , y2 ) ,…, (xn , yn ) of related data .For any xi , the observed value is yi and the expected value is axi +b so that the error = yi –(axi +b)  The sum of squares of errors is n

E   y i  f ( x i )2  y 1  (ax 1  b )2  y 2  (ax 2  b )2 i 1

 ...  y n  (ax n  b )  For the best fit , by Principle of least squares , E is minimum. E E 0 For E to be minimum  0 and a b E  0 2  y 1  (ax 1  b )( x 1 )  2y 2  (ax 2  b )( x 2 ) a  ....  2y n  (ax n  b ) ( x n )  0

2

2 2 2  [x 1 y 1  ax 1  bx1 ]  [ x 2 y 2  ax 2  bx 2 ]  ........  [ x n y n  ax n  bx n ]  0

 x 1 y1  x 2 y 2  ........  x n y n  ax 21  ax 22  ........  ax 2n  bx1  bx 2  ...  bx n n

n

n

  x i y i  a  x 2i  b  x i . .......(1) i 1

i 1

i 1

E  0 2  y1  (ax1  b ) ( 1)  2y 2  ( ax 2  b ) (1)  ....  2 yn  ( axn  b ) ( 1)  0 b  [ y 1  ax 1  b]  [ y 2  ax 2  b ]  ........  [ y n  ax n  b]  0

 y 1  y 2  .....  y n  ax 1  ax 2  .......  ax n  b  b  ........  b n

n

  y i  a  x i  nb i 1

........(2)

i 1

The equations (1) and (2) are known as Normal equations and can be solved as simultaneous equations in a and b .

Example 1 By the method of least squares find the best fitting straight line to the data x : 5 10 15 20 25 y : 15 19 23 26 30 Solution Let y = ax+b be the best fit straight line. The nomal equations are  y  a x  nb and

 xy  a  x

2

b  x

x y xy x2 5 15 75 25 10 19 190 100 15 23 345 225 20 26 520 400 25 30 750 625 75 113 1880 1375 The normal equations becomes 75a +5b = 113 1375a+75b = 1880 Solving , we get a = 0.74 , b = 11.5 Required line is y = 0.74x +11.5 Example 2 Fit a straight line of the form y = a + bx for the data given below x: 1 2 3 4 5 y : 5 7 9 10 11 Solution Lety = a+bx be the best fit straight line. The nomal equations are y  na  b  x and

 xy  a  x  b  x

2

x y xy x2 1 5 5 1 2 7 14 4 3 9 27 9 4 10 40 16 5 11 55 25 15 42 141 55 The normal equations becomes 5a+15b = 42 15a+55b = 141 Solving , we get a = 3.9 , b = 1.5 Required line is y = 3.9+ 1.5x

Fitting of parabola y = a x2 + b x + c

1.3

Let y = ax2 + bx + c be a best fit parabola to the n pairs of observations (x1 , y1 ), (x2 , y2 ) ,…, (xn , yn ) of related data .For any xi , the observed value is yi and the expected value is ax 2i  bx i  c so that the error = y i  (ax 2i  bx i  c)  The sum of squares of errors is n



  2

E   y i  f ( x i )2  y 1  (ax 21  bx 1  c)  y 2  (ax 22  bx 2  c )



2

i 1



 ....  y n  (ax 2n  bx n  c) For the best fit , by Principle of least squares , E is minimum. E E E For E to be minimum  0,  0 and 0 c a b E  0  2 y 1  (ax 21  bx 1  c) ( x 21 )  2 y 2  (ax 22  bx 2  c ) ( x 22 ) a  ....  2 y n  (ax 2n  bx n  c) ( x2n )  0









2







y 1x 21  ax 14  bx 31  cx12  y 2 x 22  ax 24  bx 3 2  c x 22  ....  y n x 2n  ax 4n  bx 3 n  cx 2n  0 y1 x 21  y2 x22  ..... yn x2n  ax41  ax42  .... axn4  bx31 bx 3 2  ..... bx3 n  cx12  c x 22  .....  cx 2n n

n

n

n

 y i x 2i  a  x 4i  b  x 3i  c  x 2i ..........(1) i 1

i 1

i 1

i 1

E  0 2 y1  (ax12  bx1  c) ( x1 )  2 y 2  (ax 22  bx2  c ) ( x2 ) b  ....  2 y n  (ax 2n  bx n  c) ( x n )  0









3 1

y 1x 1  ax  bx

2 1

3 2

 cx 1  y 2x 2  ax  bx





2

2

 c x 2  ....  y nx n ax 3n  bx 2 n  cx n  0

y 1x 1  y 2x 2  .....  y n x n  ax 31  ax 23  ....  ax n  bx 21bx 2 2  .....  bx 2 n  cx 1  c x 2 .....  cx n n

 i 1

n

n

n

i 1

i 1

i 1

yi xi  a x3i  b xi 2  c xi ..........(2)

E  0 2 y1  (ax12  bx1  c) ( 1)  2 y 2  (ax 22  bx 2  c ) ( 1) c  ....  2 y n  (ax 2n  bx n  c ) ( 1)  0









n

n





n

  y i  a  x 2i  b  x i  nc ..........(3) i 1

i 1

i 1

The equations (1) ,(2) and (3) are known as Normal equations and can be solved as simultaneous equations in a ,b and c .

Example 1 Find a second degree curve for the following data x: 1 2 3 4 5 y : 3 9 13 21 31 Solution Let y = a x2 + b x + c be the fitted second degree curve . The normal equations are  y  a x 2  b x  nc 2

 xy  a  x  b  x  c  x  x y  a x  b  x  c x 3

2

3

4

2

x y x2 x3 x4 1 3 1 1 1 2 9 4 8 16 3 13 9 27 81 4 21 16 64 256 5 31 25 125 625 sum=15 77 55 225 979 The normal equations becomes 55a+15b+5a = 77 225a+55b+15c = 299 979a+225b+55c = 1267 Solving , we get a = 1.01 , b = 0.744 , c= 2.058

xy 3 18 39 84 155 299

x2 y 3 36 117 336 775 1267

Example 2 Fit a second degree curve of the form y = a+bx+cx2 to the following data x : 1911 1912 1913 1914 1915 y : 10 12 8 10 14 Solution Let u = x -1913 Let y = a+bu+cu2 be the parabola of best fit. The normal equations are  y  a u 2  b  u  nc

uy a u b u c u u y a  x  b u  c u 3

2

2

4

3

x u = x- 1913 u2 1911 -2 4 1912 -1 1 1913 0 0 1914 1 1 1915 2 4 Sum= 0 10 The normal equations becomes 5a+0b+10c = 54 0c+10b+0c = 6 10a+0b+34c = 118

u3 -8 -1 0 1 8 0

2

u4 16 1 0 1 16 34

y 10 12 8 10 14 54

uy -20 -12 0 10 28 6

u2y 40 12 0 10 56 118

Solving , we get a = 9.37 , b = 0.6 , c = 0.714 The fitted parabola is y = 9,37+0.6u+0.714u2 = 9,37+0.6 (x-1913)+0.714(x-1913)2 Fitting of parabola y = a x2 + b

1.4

Let y = ax2 + b be a best fit parabola to the n pairs of observations (x1 , y1 ), (x2 , y2 ) ,…, (xn , yn ) of related data .For any xi , the observed value is yi and the expected value is ax 2i  b so that the error = y i (ax 2i  b)  The sum of squares of errors is n



  2

E   y i  f ( x i )2  y1  (ax 12  b )  y 2  (ax 22  b )



2

i 1





2

 ....  y n  (ax 2n  b ) For the best fit , by Principle of least squares , E is minimum. E E  0 and 0 For E to be minimum b a E  0 2 y 1  (ax 12  b ) (x 21 )  2 y 2  (ax 22  b ) (x 22 )  ....  2 y n  (ax 2n b ) (x 2n )  0 a   [x12 y 1  ax 14  bx 21 ]  [x 22 y 2  ax 42  bx 22 ]  ........  [x n2y n  ax n4  bx n2 ]  0













 x12 y 1  x 22 y 2  ........  x n2 y n  ax14  ax24  ........  ax 4n  bx 21  bx22  bx n2 n



n 2 i

x i 1

n 4 i

yi  a  x  b  xi2 . .......(1) i 1

i 1

E  0  2 y1  (ax12  b ) (1)  2 y2  (ax22  b ) (1)  ....  2 y n  ( ax2n  b ) ( 1)  0 b  y1  y2  ........  yn ax12  ax22 ...  ax2n b  b  ....  b













n

n

  yi  a xi2  nb . .......(2) i1

i 1

The equations (1) and (2) are known as Normal equations and can be solved as simultaneous equations in a and b Example Fit a parabola of the form y = a + bx2 for the data given below x: 1 2 3 4 5 y : 0.43 0.83 1.4 2.33 3.42 Solution Let y = a + bx2 be the fitted curve . The normal equations are  y  na  b  x 2

x x 1 2

2

y  ax 2  bx 4 y 0.43 0.83

x2 1 4

x4 1 16

x2 y 0.43 3.32

3 1.4 9 81 12.6 4 2.33 16 256 37,28 5 3.42 25 625 85.5 Sum= 8.41 55 979 139.13 The normal equations becomes 5a+55b = 8.41 55a+979b = 139.13 Solving , we get a = 0.307 , b = 0.125 Therefore the required equation is y = 0.307 + 0.125 x2 1.4

Fitting of the curve y = a ebx

Given y = a ebx Taking logarithm on both sides, we get log y = log a + bx Let Y = log y and A = log a . Then the above equation becomes Y = A + bx The normal equations are  Y  nA  b  x and

 xY  A  x

 b x 2 Example Fit a curve of the form y = a ebx to the following data x: 0 2 4 y : 5.012 10 31.62 Solution Given y = a ebx Taking logarithm on both sides, we get log y = log a + bx Let Y = log y and A = log a . Then the above equation becomes Y = A + bx The normal equations are  Y  nA  b  x and

 xY  A  x

 b x 2

x y Y = logy 0 5.012 1.62 2 10 2.3 4 31.62 3.45 Sum=6 46.632 7.37 The normal equations becomes 3A+6b =7.37 6A+20b = 18.4 Solving , we get A = 1.534 , b = 0.46 A = 1.534  a = 4.64 Therefore the required equation is y = 4.64 e0.46x

x2 0 4 16 20

xY 0 4.6 13.8 18.4...


Similar Free PDFs