90 likes | 267 Views
Chapter 5. Curve Fitting and Interpolation: Lecture (IV). 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. Introduction. Regression
E N D
Chapter 5 Curve Fitting and Interpolation: Lecture (IV) Dr. Jie Zou PHY 3320
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
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
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. Residual error Inadequate criterion: Minimize Dr. Jie Zou PHY 3320
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: Dr. Jie Zou PHY 3320
Example: Linear regression • Use least-square regression, fit a straight line to the values in the table below. Best fit line: F = -234.2857 + 19.47024 v Dr. Jie Zou PHY 3320
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. Before Dr. Jie Zou PHY 3320 After
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
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. Dr. Jie Zou PHY 3320