Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
34 views

Curve Fitting: Instructor: Dr. Aysar Yasin Dep. of Energy and Env. Engineering

This document provides an introduction to curve fitting. It discusses two general approaches: least-squares regression, which derives a single curve to describe trends in data that has errors, and interpolation, which fits curves through each data point for precise data. It then focuses on using least-squares regression to fit a straight line to data, including finding the slope and intercept through minimizing the sum of the squared residuals and calculating the coefficient of determination. Two examples are shown to demonstrate fitting a line to sets of x and y data values.

Uploaded by

Ameer Alfuqaha
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Curve Fitting: Instructor: Dr. Aysar Yasin Dep. of Energy and Env. Engineering

This document provides an introduction to curve fitting. It discusses two general approaches: least-squares regression, which derives a single curve to describe trends in data that has errors, and interpolation, which fits curves through each data point for precise data. It then focuses on using least-squares regression to fit a straight line to data, including finding the slope and intercept through minimizing the sum of the squared residuals and calculating the coefficient of determination. Two examples are shown to demonstrate fitting a line to sets of x and y data values.

Uploaded by

Ameer Alfuqaha
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Curve Fitting

Instructor: Dr. Aysar Yasin

Dep. Of Energy and Env. Engineering


Curve Fitting
Introduction
? What is Curve Fitting
!!!General Approaches of Curve Fittings
Least-squares Regression : derive a single .1
.curve to describe a general trend of the data
)data exhibit significant degree of errors(
Interpolation: Fitting a curve or series of .2
curves that pass directly through each of the
.points
)Precise Data(
Curve Fitting
Introduction
Non computer method for curve fitting, but this is dependent to-
.subjective viewpoint of the person sketching the curve

Curves are used to capture General upward trend


The meanderings suggested Of the data with a
By the data straight line
Curve Fitting
Orientation
Least Square Regression
Linear Regression
:Mathematical expression of a straight line
y x
y=a0+a1x+e
    a1- slope
    a0- intercept
   

e= y-a0-a1x
e- error, or residual, between the model and the
observations
Eng. Muhannad Al-Jabi
Best strategy is to minimize the sum of the •
squares of the residuals between the measured
:y and the y calculated with the linear model
n n n
S r   ei2   ( yi , measured  yi , model) 2   ( yi  a0  a1 xi ) 2
i 1 i 1 i 1

.Yields a unique line for a given set of data •


We need to study techniques to find the constants

Eng. Muhannad Al-Jabi


/Least-Squares Fit of a Straight Line
To find the values of constants we need to differentiate Sr with respect to each coefficient

S r
 2 ( yi  ao  a1 xi )  0
ao
S r
 2  ( yi  ao  a1 xi ) xi   0
a1
0   yi   a 0   a1 xi
0   yi xi   a 0 xi   a1 xi2

Eng. Muhannad Al-Jabi


/Least-Squares Fit of a Straight Line

a 0  na0 Normal equations, can be


na0    xi  a1   yi solved simultaneously

n xi yi   xi  yi
a1 
n x    xi 
2 2
i Mean values
a0  y  a1 x

Eng. Muhannad Al-Jabi


Goodness” of our fit“
If
Total sum of the squares around the mean for the dependent •
  ( yi  y ) 2 variable, y, is St
Sum of the squares of residuals around the regression line is Sr •
St-Sr quantifies the improvement or error reduction due to •
describing data in terms of a straight line rather than as an
.average value
St  S r
r 
2

St r2-coefficient of determination
r– correlation coefficient

Eng. Muhannad Al-Jabi


For a perfect fit •
Sr=0 and r=r2=1, signifying that the line explains
.100 percent of the variability of the data
For r=r2=0, Sr=St, the fit represents no •
.improvement

Eng. Muhannad Al-Jabi


Example
Fit a straight line to the following values of x •
.and y
X y
1 0.5
2 2.5
3 2
4 4
5 3.5
6 6
7 5.5

Eng. Muhannad Al-Jabi


Solution
x y X2 x*y

n xi yi   xi  yi
1 0.5 1 0.5
a1  2 2.5
n x    xi 
2 4 5
2
i 3 2 9 6
4 4
a0  y  a1 x 16 16
5 3.5 25 17.5
6 6 36 36
7 5.5 49 38.5
28 24 140 119.5
4 3.428

7(119.5)  28(24)
a1   0.8392
7(140)  (28) 2

a0  3.428  0.8392(4)  0.071428


Eng. Muhannad Al-Jabi
Calculate Sr
Calculate Sr for the previous example •
X y 2
)yi-0.0714-0.8392xi(
1 0.5 0.168686
2 2.5 0.5625
3 2 0.347258
4 4 0.326531
5 3.5 0.589605
6 6 0.797194
7 5.5 0.199298
2.991071

Eng. Muhannad Al-Jabi


Calculate St

X y 2 )y-yavg(
1 0.5 8.576531
2 2.5 0.862245
3 2 2.040816
4 4 0.326531
5 3.5 0.005102
6 6 6.612245
7 5.5 4.290816
Avg(y)=3.428 22.71429

Eng. Muhannad Al-Jabi


Calculate r2-coefficient of determination

St  S r
r 
2

St

22.71429  2.991071
r 
2
 0.868
22.71429

Eng. Muhannad Al-Jabi


Calculate the standard error of the estimate

Sr
Sy/x 
n2

2.9911
Sy/x   0.7735
72

Eng. Muhannad Al-Jabi


Example
use least square regression to fit a straight line
-:to
X 6 15 23 30 39
Y 29 14 7 13 3

Eng. Muhannad Al-Jabi


Solution

X 6 15 23 30 39 113
Y 29 14 7 13 3 66
X *Y
174 210 161 390 117 1052
X2
36 225 529 900 1521 3211

5 *1052  113 * 66
a1   0.6689
5 * 3211  113 2

a0 = (66/5)-( -0.6689)*(113/5) = 28.3171

Eng. Muhannad Al-Jabi

You might also like