Chapter 5
-
Upload
ahmed-lott -
Category
Documents
-
view
22 -
download
0
description
Transcript of Chapter 5
Dr. Jie Zou PHY 3320 1
Chapter 5
Curve Fitting and Interpolation: Lecture (IV)
Dr. Jie Zou PHY 3320 2
Outline
Least-square regression Introduction-What is regression?
When do we use it? Linear (least-square) regression
What is linear regression? What is “least-square”? Accuracy of linear regression
Dr. Jie Zou PHY 3320 3
Introduction Regression
What is it? - To derive an approximating function or curve that represents the general trend of the data. The curve does not necessarily pass through all the data points.
When do we use it? - Usually used when the data appear to have significant error.
Linear regression
Non-linear regression
Dr. Jie Zou PHY 3320 4
Linear least-square regression
Linear regression: Fit a “best” line to the data.
Fitting function: y = a0 + a1x Parameters a0 and a1 are to be
determined. Residual error:
ei = yi – a0 – a1xi, i= 1, 2, … ei: residual error at each data point
Least-square criterion for a “best” fit:
Minimize with respect to the parameters a0 and a1.
n
i
n
iiii xaaye
1 110
n
i
n
iiii xaayeS
1 1
210
2
Residual error
Inadequate criterion: Minimize
Dr. Jie Zou PHY 3320 5
Derivation of the linear least-square regression Best straight line: y = a0 + a1x Determine a0 and a1: Apply the least-square
criterion Minimize with respect to a0
and a1
Set
Solve the simultaneous linear equations for a0 and a1:
n
i
n
iiii xaayeS
1 1
210
2
n
iiii
n
iii xxaay
a
Sxaay
a
S
110
1110
0
.02 and 02
111
0
1
2
1
2
1 111
11 and ax
ny
na
xxn
yxyxna
n
ii
n
ii
n
i
n
iii
n
i
n
ii
n
iiii
Dr. Jie Zou PHY 3320 6
Example: Linear regression Use least-square regression, fit a
straight line to the values in the table below.v
(m/s)10 20 30 40 50 60 70 80
F (N) 25 70 380 550 610 1220
830 1450
Best fit line:
F = -234.2857 + 19.47024 v
Dr. Jie Zou PHY 3320 7
Accuracy of linear regression
To quantify the “goodness” of our fit:
The residual error before regression:
The residual error after regression:
The difference between S0 and S provides a measure of the accuracy of regression or the extent of improvement achieved by the least-square fit.
Correlation coefficient: A good least-square fit is indicated by a
large value or r; rmax = 1.0.
2
10
n
i
yyS
n
iii xaayS
1
210
0
0
S
SSr
Before
After
Dr. Jie Zou PHY 3320 8
Example: Correlation coefficient
In the previous example on Slide #6, calculate the correlation coefficient r for the best fit line. Answer: r = (0.8805)1/2 = 0.9383 “These results indicate that 88.05% of
the original uncertainty has been explained by the linear model” (textbook by Chapra, p. 299).
Dr. Jie Zou PHY 3320 9
Implementation on a computer
For the example on Slide #6, write an M-file, Mylinearregression.m, to find the best fit line using the method of least-squares.
Plot the original discrete data points (in open circles) and the best fit line on the same figure.