model fitting

13
MODEL FITTING jiangyushan

Upload: timothy-bradshaw

Post on 31-Dec-2015

27 views

Category:

Documents


3 download

DESCRIPTION

MODEL FITTING. jiangyushan. Introduction. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: MODEL FITTING

MODEL FITTING

jiangyushan

Page 2: MODEL FITTING

Introduction

The goal of model fitting is to choose values for the parameters in a function to best describe a set of data. There are many possible reason to do this. If a specific meaningful form for the function with a small number of free parameters is known in advance, this is called parametric fitting, and finding the parameter values themselves may be the goad (for example, measuring an exponential decay constant to determine a reaction rate).

:{( , ) |1 }k kD x y k n

Page 3: MODEL FITTING

Visual Model Fitting with the Original Data

Suppose we want to fit the model to the data shown in Fig2.1. How might we choose the constants and to determine the line that best fits the data? Generally, when more than two data points exist, all of them cannot be expected to lie exactly along a single straight line, even if such a line accurately models the relationship between the two variables .

y ax b

andx y

ab

x

y

?

Fig2.1

Page 4: MODEL FITTING

Interpolation

• The most straightforward way to fit a curve to the data D is to find a function f that passes through each of the n data points or samples. That is , find a function f such that

( ) ,1 (2.1)k kf x y k n

Once a function is determined that satisfies (2.1) ,the value of y at other points can be estimated. In this case, the process of estimating y is referred to as interpolation.

Page 5: MODEL FITTING

Main Method for Interpolation and Curfitting

Piecewise-Linear Interpolation

Polynomial Interpolation

Lagrange Interpolating Polynomials

Newtons’s Difference Formula

Cubic Splines

Chebyshev Approximation Criterion

Least squares curvefiting

Page 6: MODEL FITTING

Matlab Functions

• poly,interp1,spline, pchip, polyfit, polyval

• Lsqnonlin, lsqcurvefit, regress, nlinfit

Page 7: MODEL FITTING

Piecewise-Linear Interpolationinterp11-D data interpolation (table lookup)Syntaxyi = interp1(x,Y,xi)yi = interp1(Y,xi)yi = interp1(x,Y,xi,method)yi = interp1(x,Y,xi,method,'extrap')yi = interp1(x,Y,xi,method,extrapval)pp = interp1(x,Y,method,'pp')Descriptionyi = interp1(x,Y,xi) interpolates to find yi, the values of the underlying function Y at the points in the vector or array xi. x must be a vector. Y can be a scalar, a vector, or an array of any dimension.

Page 8: MODEL FITTING

Visual Model Fitting with the Original Data

Ordinarily, there will be some vertical discrepancy between a few of the data points and any particular line under consideration. We refer to these vertical discrepancies as absolute deviations (Fig 2.2). For the best-fitting line, we might try to minimize the sum of these absolute deviations, leading to the model depicted in Fig2.2. Although success may be achieved in minimizing the sum of the absolute deviations, the absolute deviation from individual points may be quite large. For example, consider point D in Fig2.2. If the modeler has confidence in the accuracy of this data point, there would be concern for the predictions made from the fitted line near the point. As an alternative, suppose a line is selected that minimizes the largest deviation from any point. Applying this criterion to the data points might give the line shown in Fig2.3.

Page 9: MODEL FITTING

Visual Model Fitting with the Original Data

x

y

Fig2.2 minimizing the sum of these absolute deviations from the fitted line

Absolute deviation

x

y

Fig2.3 minimizing the largest absolute deviations from the fitted line

D

Page 10: MODEL FITTING

lsqcurvefit

• x = lsqcurvefit(fun,x0,xdata,ydata)• Solve nonlinear curve-fitting (data-fitting) proble

ms in least-squares sense• Equation:Find coefficients x that best fit the equa

tion

• given input data xdata, and the observed output ydata, where xdata and ydata are matrices or vectors of length n, and F (xdata) is a matrix-valued or vector-valued function.

2min ( ( ) ) (2.2)k

f xdata ydata

Page 11: MODEL FITTING

Objectives

• Understand the difference between interpolation and curvefitting

• Know how to express piecewise-linear interpolation parametrically

• Know why interpolation with high-degree polynomials is undesirable

• Known why finding the interpolating polynomial by solving a linear algebraic system can be inaccurate.

Page 12: MODEL FITTING

Objectives

• Know how to construct and use Largrange interpolating polynomials to perform interpolation

• Be able to fit curves to the underlying trend of data using least-squares techniques.

• Understand how curve fitting techniques can be used to solve practical engineering problems.

• Understand the relative strengths and weaknesses of each computational method and know which are most applicable for a given problem.

Page 13: MODEL FITTING

The following data represent the growth of a population of fruit flies over a 6-week period. Test the following models by plotting an appropriate set of data. Estimate the parameters of the models:

The growth of a population of fruit flies

1 2x x

T (days) 7 14 21 28 35 42

P (number of observed flies) 8 41 133 250 280 297

p ct

btp ae