Least Squares Fitting of Data to a Curve

Least Squares Fitting of Data to a Curve

Gerald Recktenwald Portland State University Department of Mechanical Engineering

gerry@me.pdx.edu

These slides are a supplement to the book Numerical Methods with Matlab: Implementations and Applications, by Gerald W. Recktenwald, c 2000?2007, Prentice-Hall, Upper Saddle River, NJ. These slides are copyright c 2000?2007 Gerald W. Recktenwald. The PDF version of these slides may be downloaded or stored or printed only for noncommercial, educational use. The repackaging or sale of these slides in any form, without written consent of the author, is prohibited. The latest version of this PDF file, along with other supplemental material for the book, can be found at recktenwald or web.cecs.pdx.edu/~gerry/nmm/.

Version 0.82 November 6, 2007

page 1

Overview

? Fitting a line to data Geometric interpretation Residuals of the overdetermined system The normal equations

? Nonlinear fits via coordinate transformation ? Fitting arbitrary linear combinations of basis functions

Mathematical formulation Solution via normal equations Solution via QR factorization ? Polynomial curve fits with the built-in polyfit function ? Multivariate fitting

NMM: Least Squares Curve-Fitting

page 2

Fitting a Line to Data

Given m pairs of data: (xi, yi), i = 1, . . . , m

Find the coefficients and such that

F (x) = x +

is a good fit to the data Questions: ? How do we define good fit? ? How do we compute and after a definition of "good fit" is obtained?

NMM: Least Squares Curve-Fitting

page 3

Plausible Fits

Plausible fits are obtained by adjusting the

5

slope () and intercept (). Here is a

graphical representation of potential fits to a

4

particular set of data

y

3

Which of the lines provides the best fit?

2

1 123456 x

NMM: Least Squares Curve-Fitting

page 4

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download