Beruflich Dokumente
Kultur Dokumente
Saharudin Haron
Page 5 - 1
Curve Fitting
Page 5 - 2
Least-squares Regression
2 types of fitting:
a) Linear regression
b) Polynomial regression
Page 5 - 3
Linear Regression
Fitting a straight line that represents the general trend of the data.
y = ao + a1x + e
where
e = error or residual
a1 =
n xi y i - xi y i
n x i - ( x i )
2
a o = y - a1 x
yi
n
xi
x=
n
y=
n = number of points
2
a1 = slope
a o = intercept
y = arithmetic mean of y
x = arithmetic mean of x
Page 5 - 4
Linear Regression
Example 5.1:
Table 1
2
3
4
2.5 2.0 4.0
5
3.5
6
6.0
7
5.5
a1 = 0.8392857
a0 = 0.07142857
sy =
St
n 1
s t = ( yi y )
sy =
St
n 1
Regression error, Sr
n
s r = e = ( y i - a o - a 1x i )
i =1
2
i
i =1
s y/x =
Sr
n2
Coefficient of determination
r2 =
S t Sr
St
or
r = r2
- correlation coefficient
i.e. r2 = 0.923 - indicate that 92.3 % of the original uncertainty has been
explained by the linear model
Page 5 - 7
yi
0.5
2.5
2.0
4.0
3.5
6.0
5.5
24.0
(yi- y )2
8.5765
0.8622
2.0408
0.3265
0.0051
6.6122
4.2908
22.7143
(yi-ao-a1xi)2
0.1687
0.5625
0.3473
0.3265
0.5896
0.7972
0.1993
2.9911
Page 5 - 8
Linear Regression
(assignment in class)
Table 1 shows data of the tensile strength of a plastic versus the heating time.
Time
10
15
20
25
40
50
55
60
75
Tensile
strength
20
18
50
33
48
80
60
78
Table 1
Fit a straight line to this data and calculate the standard deviation, standard
error of the estimate and coefficient of determination of the linear model. Use
the equation to determine the tensile strength at a time of 30 minutes.
Page 5 - 10
Least-squares Regression
(assignment)
Time
10
15
20
25
30
35
40
45
50
Tensile
strength
25
32
33
38
36
39
40
42
42
Table 1
Use least-squares regression to fit (a) an exponential equation, (b) a power
equation, (c) a saturation-growth-rate equation, and (d) a parabola, to the data
in Table 1. Is any one of the curves superior? If so, justify.
Page 5 - 11
Interpolation
To estimate intermediate values between precise data points. The most
common method used for this purpose is polynomial interpolation.
General formula for an nth-order polynomial
f(x) = ao + a1x + a2x2 + .. + anxn
Several methods of interpolating polynomials such as :
1st order (linear) connecting 2 points.
2nd order (quadratic or parabolic) connecting 3 points.
3rd order (cubic) connecting 4 points.
The techniques that will be used are:Newtons Interpolating Polynomials
Lagrange Interpolating Polynomial
Splines Interpolation
Page 5 - 12
x1
Page 5 - 13
where :
b0 = f(x0)
f(x1) - f(x0)
b1 = f [x1, x0] =
x1 - x0
b = f [x , x , x ] =
2
2 1 0
where :
f [x1, x0] =
f(x1) - f(x0)
x1 - x0
10
15
20
25
30
Applied stress,
kg/mm2
11.6
10.3
9.1
8.2
7.4
6.8
Estimate the fracture time for an applied stress of 8.5 kg/mm2. Use Newton
interpolation of order 3.
Page 5 - 16
fn(x) = Li(x)f(xi)
i=0
n
where
Li(x) =
x xj
xi x j
j =0
j i
Page 5 - 17
x x0
x x1
f ( x0 ) +
f ( x1 )
f1 ( x ) =
x0 x1
x1 x0
If n = 2
f2 ( x) =
( x x0 )( x x2 )
( x x1 )( x x2 )
f ( x0 ) +
f ( x1 )
( x0 x1 )( x0 x2 )
( x1 x0 )( x1 x2 )
( x x0 )( x x1 )
f ( x2 )
( x2 x0 )( x2 x1 )
Page 5 - 18
Splines Interpolation
3 cases:
Linear Splines
Quadratic Splines
Cubic Splines
Linear Splines
- is a simplest method where a straight line is drawn to connect 2 points.
- a group of ordered data points can be defined as a set of linear functions.
Page 5 - 19
Splines Interpolation
A set of linear functions can be shown as below :-
x0 x x1
x1 x x2
xn-1 x xn
where
mi = f(xi+1) - f(xi)
xi+1 - xi
Page 5 - 20
Splines Interpolation
Example : Fit the data below with first order Splines. Evaluate the
function at x = 5
x
3.0
4.5
7.0
9.0
f(x)
2.5
1.0
2.5
0.5
Splines Interpolation
Quadratic Splines
the objective in quadratic splines is to derive a second order polynomial
for interval between data points.
The polynomial for each interval can be represented generally as :
fi(x) = ai x2 + bi x + ci - general equation for Quadratic Splines
For n+1 data points, ( i = 0, 1, 2,.n) there are n intervals and
consequently, 3n unknowns constants (the as, bs and cs) to evaluate.
Page 5 - 22
Splines Interpolation
Conditions that are required to evaluate the unknowns
The function values must be EQUAL at the interior knots. This condition
can be represented as :
Splines Interpolation
Conditions that are required to evaluate the unknowns
The first derivatives at the interior knots must be equal.
for i = 2 to n
a1 = 0
Page 5 - 24
Splines Interpolation
Cubic Splines
- the objective is to derive a third order polynomial for each interval.
fi (x) = ai x3 + bi x2 + ci x + di
For a quadratic splines, 4n conditions are required to evaluate the
unknowns.These are :
The function values must be equal at the interior knots (2n-2 conditions)
The first and last functions must pass through the end points (2 conditions)
The first derivatives at the interior knots must be equal (n-1 conditions)
The second derivatives at the interior knots must be equal (n-1 conditions)
The second derivatives at the end knots are zero (2 conditions)
Page 5 - 25
Splines Interpolation
assignment in class
Given the data:
x
2.5
f(x)
Page 5 - 26