Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Curve Fitting:
Fitting a Straight Line
Least Square Regression
Curve Fitting
Statistics Review
Linear Least Square Regression
Linearization of Nonlinear
Relationships
MATLAB Functions
Wind Tunnel Experiment
Curve
Fitting
v, m/s 10 20 30 40 50 60 70 80
F, N 25 70 380 550 610 1220 830 1450
Simple Statistics
Measurement of the coefficient of thermal expansion
of structural steel [106 in/(inF)]
n
Standard deviation about the mean
; St yi y
St 2
sy
n1
Variance (spread)
y y y y
2 2 2
/n
2 i i i
s
n1 n1
y
S t yi y 0.406514
2
Sum of the square of residuals
yi2 yi / n
2
1554.198 ( 236.509 ) 2 / 36
s
2
Variance
n1
y
35
0.406514
0.0116147
35
sy 0.10777
c .v . 100% 100% 1.64% Coefficient of variation
y 6.5697
xx
2
Histogram p( x )
1
2
exp
2 2
Normal
Distribution
y a0 a1 x
Difference between observation and line
yi a0 a1 xi e i
ei is the residual or error
Least Squares Approximation
e (y
i 1
i
i 1
i a0 a1 x i )
Minimize Sum of
Absolute Errors
n n
e
i 1
i yi a0 a1 x i
i 1
Minimize the
Maximum Error
Linear Least Squares
( x1 , y1 ) , ( x 2 , y 2 ) , ( x 3 , y 3 ) , , ( x n , y n )
S r n n n
a 0 2 yi a0 a1 x i na0 x i a1 yi
0 i 1 i 1 i 1
n
S r 0 2 y a a x x x a x 2 a
n n n
a1 i 0 1 i i
i 0 i 1 x i yi
i 1 i 1 i 1 i 1
a0 ya x
y i
a1
x i
1
n n
Advantage of Least Squares
xx i , S x x i ,
2
S x
i 1 i 1
let n n
S
xy
i 1
x i y i , S y yi
i 1
n S x a0 Sy
S
x S xx a1 S xy
S xx S y S xy S x nS xy S x S y
a0 , a1
nS xx S 2
x nS xx S x2
Linearization of Nonlinear Relationships
Untransformed
power equation
x vs. y
transformed data
log x vs. log y
Linearization of
Nonlinear Relationships
Exponential equation
1 x
y 1e
ln y ln 1 1 x
use xi , ln yi instead of xi , yi
Power equation
y 2 x 2
log :
log y log 2 2 log x
Base-10
use log xi , log yi instead of xi , yi
Linearization of
Nonlinear Relationships
Saturation-growth-rate equation
x 1 1 3 1
y 3
3 x y 3 3 x
1 1
use , instead of x i , yi
x i yi
Rational function
1 1
y 4 x 4
4 x 4 y
1
use x i , instead of x i , yi
yi
Example 12.4: Power Equation
Transformed
Data
log xi vs. log yi
y = 2 x 2
Power equation fit
along with the data
x vs. y
>> x=[10 20 30 40 50 60 70 80];
>> y = [25 70 380 550 610 1220 830 1450];
>> [a, r2] = linregr(x,y)
a =
19.4702 -234.2857
r2 = y = 19.4702x 234.2857
0.8805
12-12
>> x=[10 20 30 40 50 60 70 80];
>> y = [25 70 380 550 610 1220 830 1450];
>> linregr(log10(x),log10(y))
r2 =
0.9481 log y = 1.9842 log x – 0.5620
ans = y = (10–0.5620)x1.9842 = 0.2742 x1.9842
1.9842 -0.5620
12-13
MATLAB Functions
Least-square fit of nth-order polynomial
p = polyfit(x,y,n)
f ( x ) p1 x n1 p2 x n 2 pn1 x pn
y = polyval(p,x)
Large error,
poor correlation
Preferable to
fit a parabola
Polynomial Regression
Quadratic Least Squares
y = f(x) = a0+ a1x + a2x2
Minimize total square error
n
Sr ( a0 , a1 , a2 ) ( yi a0 a1 x i a2 x i2 ) 2
i 1
Sr
n
a 0 2 y i a0 a x
1 i a x
2 i
2
0 i 1
Sr
n
0 2 x y a a x a x 2
a1
i i 0 1 i 2 i
i 1
S
n
r 0 2 x i yi a0 a1 x i a2 x i
2 2
a 2 i 1
Quadratic Least Squares
n n
n
n x i 2
xi yi
n i 1 i 1
a0 i 1
3
n n n
x
i
x 2
x i a1 x i yi
i 1
i
i 1 i 1
i 1
n n n a2 n
x i2 i
x 3
x 4
x 2
y
i i
i 1
i
i 1 i 1 i 1
n n n
n
n x x i
2
i 3
x
i yi
n i 1
n
i 1
n
i 1
n a n
i 1
x x i x i yi
4
i i
2 3 0
x x
i
a1 i 1
a n
i 1 i 1 i 1 i 1
n n n n
x i2 i
x 3
i
x 4
x 5 2
x 2
i yi
a3 i 1
i
i 1 i 1 i 1 i 1
n 3 n n n
n
xi i i x i yi
4 5 6 3
x x xi
i 1 i 1 i 1 i 1 i 1
Linear Least Square: y = – 20.5717 + 3.6005x
Quadratic: y = 0.2668 + 0.7200 x 2.7231x2
Cubic: y = 0.6513 + 1.5946x – 2.8078x2 0.0608x3