2.1 FULL Content
2.1 FULL Content
ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE
AND ENGINEERING
2
Curve Fitting:
• Curve fitting, on the other hand, is a broader concept that encompasses various methods to
approximate the shape of a curve based on a set of observed data points.
• While polynomial interpolation is one specific technique for curve fitting, there are other
approaches such as linear regression, spline interpolation, and least squares fitting.
• Curve fitting is particularly valuable when dealing with noisy or incomplete data, as it helps in
uncovering patterns and trends within the dataset.
• The choice of the fitting method depends on the nature of the data and the desired
characteristics of the fitted curve.
3
Interpolation and Curve Fitting
Given the n + 1 data points (xi, yi), i = 0, 1, ... , n, estimate y(x).
Introduction Discrete data sets, or tables of the form
4
Polynomial Interpolation Lagrange’s Method
5
6
7
Newton’s Method
Although Lagrange’s method is conceptually simple, it does not lend itself to an efficient algorithm. A better computational
procedure is obtained with Newton’s method, where the interpolating polynomial is written in the form
8
If the coefficients are computed by hand, it is convenient to work with the format in Table 3.1 (shown for n = 4).
9
The diagonal terms (y0, ∇y1, ∇2y2, ∇3y3, and ∇4 y4) in the table are the coefficients of the polynomial. If the data
points are listed in a different order, the entries in the table will change, but the resultant polynomial will be the same—
recall that a polynomial of degree n interpolating n + 1 distinct data points is unique.
10
Least-Squares Fit
• The task of curve fitting is to find a smooth curve that fits the data points “on the average.”
• This curve should have a simple form (e.g., a low-order polynomial), so as to not reproduce
the noise.
Let f(x) = f(x;a0, a1, ... , am)
• be the function that is to be fitted to the n + 1 data points (xi, yi), i = 0, 1, ... , n.
• The notation implies that we have a function of x that contains m + 1 variable parameters a0,
a1, ... , am, where m < n.
• The form of f(x) is determined beforehand, usually from the theory associated with the
experiment from which the data are obtained.
• The only means of adjusting the fit are the parameters. For example, if the data represent the
displacements yi of an over-damped mass-spring system at time ti, the theory suggests the
choice f(t) = a0te−a1t .
• Thus curve fitting consists of two steps: choosing the form of f(x), followed by computation of
the parameters that produce the best fit to the data.
11
• This brings us to the question: What is meant by the “best” fit? If the noise is confined to the
y-coordinate, the most commonly used measure is the least-squares fit, which minimizes the
function
with respect to each aj . Therefore, the optimal values of the parameters are given by the
solution of the equations
he terms ri = yi − f(xi) in Eq. (3.13) are called residuals; they represent the discrepancy between
the data points and the fitting function at xi. The function S to be minimized is thus the sum of
the squares of the residuals. Equations (3.14) are generally nonlinear in aj and may thus be
difficult to solve. Often the fitting function is chosen as a linear combination of specified
functions fj(x),
12
in which case Eqs. (3.14) are linear. If the fitting function is a polynomial, we have f0(x) = 1, f1(x)
= x, f2(x) = x2, and so on. The spread of the data about the fitting curve is quantified by the
standard deviation, defined a
Note that if n = m, we have interpolation, not curve fitting. In that case both the numerator and
the denominator in Eq. (3.15) are zero, so that σ is ind
13
Fitting a Straight Line
14
15
Fitting Linear Forms
Consider the least-squares fit of the linear form
where each fj(x) is a predetermined function of x, called a basis function. Substitution in Eq.
(3.13) yields
16
Polynomial Fit
only low-order polynomials are useful in curve fitting. Polynomials of high order are not recommended, because
they tend to reproduce the noise inherent in the data. 17
PolyFit
• The function polyFit in this module sets up and solves the normal equations for the
coefficients of a polynomial of degree m.
18
19
Basic Algebra
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
THANK YOU
38