SlideShare a Scribd company logo
1 of 16
Download to read offline
1
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Regression/Curve Fitting
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Objectives
• Understanding the difference between
regression and interpolation
• Knowing how to “best fit” a polynomial into
a set of data
• Knowing how to use a polynomial to
interpolate data
2
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Measured Data
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Polynomial Fit!
3
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Line Fit!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Which is better?
4
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Curve Fitting
• If the data measured is of high accuracy
and it is required to estimate the values of
the function between the given points,
then, polynomial interpolation is the best
choice.
• If the measurements are expected to be of
low accuracy, or the number of measured
points is too large, regression would be
the best choice.
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Regression
5
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Why Regression?
• Measurements that we get from real
situations are not usually consistent!
• The number of “pieces” of information that
we can get about a certain project is
HUGE
• You can NEVER measure exact values!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Measured Data
6
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
But, how to get the equation of a
line that is “good” for all the data
you have!
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Equation of a Line: Revision
xaay 10 +=
If you have two points
1101 xaay +=
2102 xaay += 





=












2
1
1
0
2
1
1
1
y
y
a
a
x
x
7
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solving for the constants!
12
12
1
12
2112
0 &
xx
yy
a
xx
yxyx
a
−
−
=
−
−
=
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
What if I have more than two
points?
8
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
For every point
nn xaay
xaay
xaay
10
2102
1101
+≠
+≠
+≠
M 

















≠














1
02
1
2
1
1
1
1
a
a
x
x
x
y
y
y
nn
MMM
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
So, we may write the error vector


















−














=














1
02
1
2
1
2
1
1
1
1
a
a
x
x
x
y
y
y
e
e
e
nnn
MMMM
{ } { } [ ] { } 1*22*1*1* aAye nnn −=
9
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Square the error
{ } { } [ ]{ }aAye −=
{ } { } { } { } { } [ ]{ }
{ } [ ] { } { } [ ] [ ]{ } 2
eaAAayAa
aAyyyee
TTTT
TTT
=+−
−=
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Note: this is a scalar equation!
{ } { } { } { } { } [ ]{ }
{ } [ ] { } { } [ ] [ ]{ } 2
eaAAayAa
aAyyyee
TTTT
TTT
=+−
−=
{ } [ ]{ } { } [ ] { }yAaaAy
TTT
=
{ } { } { } [ ] { } { } [ ] [ ]{ }aAAayAayye
TTTTT
+−= 2
2
10
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Note: this is a quadratic equation in {a}!!!
{ } { } { } [ ] { } { } [ ] [ ]{ }aAAayAayye
TTTTT
+−= 2
2
To minimize the error in the above equation, we need to
differentiate with respect to the parameters
{ }
[ ] { } [ ] [ ]{ } 022
2
=+−= aAAyA
ad
ed TT
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solving the equation
We get:
{ }
[ ] { } [ ] [ ]{ } 022
2
=+−= aAAyA
ad
ed TT
[ ] [ ] { } [ ] { } 1**21*22**2 n
T
nn
T
n yAaAA =
[ ] { } { } 1*21*22*2 yaA = { } [ ] { }yAa
1−
=
11
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Example
• If you are given the
data.
• Find the equation of
the “best-fit” line.
y=a1+a2x
5.57
66
3.55
44
23
2.52
0.51
yx
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution






















=




























5.5
6
5.3
4
2
5.2
5.0
71
61
51
41
31
21
11
1
0
a
a
[ ] { }






















=






















=
5.5
6
5.3
4
2
5.2
5.0
&
71
61
51
41
31
21
11
yA
12
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution
[ ] [ ] 





=




























=
14028
287
71
61
51
41
31
21
11
7654321
1111111
AA
T
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution
[ ] { }






=




























=
5.119
24
5.5
6
5.3
4
2
5.2
5.0
7654321
1111111
yA
T
13
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution






=












5.119
24
14028
287
1
0
a
a
[ ] [ ]{ } [ ] { }yAaAA
TT
=






=






8393.0
0714.0
1
0
a
a
0714.08393.0 += xy
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Example
• If you are given the
data.
• Find the equation of
the “best-fit” parabola.
y=a0+a1x+a2x2
5.57
66
3.55
44
23
2.52
0.51
yx
14
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution






















=
































5.5
6
5.3
4
2
5.2
5.0
49
36
25
16
9
4
1
71
61
51
41
31
21
11
2
1
0
a
a
a
[ ] { }






















=






















=
5.5
6
5.3
4
2
5.2
5.0
&
49
36
25
16
9
4
1
71
61
51
41
31
21
11
yA
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution
[ ] [ ]










=
































=
4676784140
78414028
140287
49
36
25
16
9
4
1
71
61
51
41
31
21
11
49362516941
7654321
1111111
AA
T
15
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution
[ ] { }










=
































=
5.665
5.119
24
5.5
6
5.3
4
2
5.2
5.0
49362516941
7654321
1111111
yA
T
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Solution
[ ] [ ]{ } [ ] { }yAaAA
TT
=










−
−
=










0298.0
0774.1
2857.0
2
1
0
a
a
a
2857.00774.10298.0 2
−+−= xxy
16
ENEM602 Spring 2007
Dr. Eng. Mohammad Tawfik
Homework #4
• Chapter 17, pp. 471-472, numbers:
17.4,17.5.
• Use the data and regression to get the
equation of the line that best fits the data
• Number 17.7
• Use the data and regression to get the
equation of the line and the parabola that
best fit the data

More Related Content

What's hot

MCA_UNIT-1_Computer Oriented Numerical Statistical Methods
MCA_UNIT-1_Computer Oriented Numerical Statistical MethodsMCA_UNIT-1_Computer Oriented Numerical Statistical Methods
MCA_UNIT-1_Computer Oriented Numerical Statistical MethodsRai University
 
Adomian decomposition Method and Differential Transform Method to solve the H...
Adomian decomposition Method and Differential Transform Method to solve the H...Adomian decomposition Method and Differential Transform Method to solve the H...
Adomian decomposition Method and Differential Transform Method to solve the H...IJERA Editor
 
Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...
Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...
Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...IOSR Journals
 
MCA_UNIT-2_Computer Oriented Numerical Statistical Methods
MCA_UNIT-2_Computer Oriented Numerical Statistical MethodsMCA_UNIT-2_Computer Oriented Numerical Statistical Methods
MCA_UNIT-2_Computer Oriented Numerical Statistical MethodsRai University
 
Direct and indirect methods
Direct and indirect methodsDirect and indirect methods
Direct and indirect methodsEjaz hussain
 
Definition of statistical efficiency
Definition of statistical efficiencyDefinition of statistical efficiency
Definition of statistical efficiencyRuhulAmin339
 
Top schools in noida
Top schools in noidaTop schools in noida
Top schools in noidaEdhole.com
 
Fixed point Iterative Method
Fixed point Iterative MethodFixed point Iterative Method
Fixed point Iterative MethodNasima Akhtar
 
Measures of Central tendency
Measures of Central tendencyMeasures of Central tendency
Measures of Central tendencyEdrin Jay Morta
 
Elements of Statistical Learning 読み会 第2章
Elements of Statistical Learning 読み会 第2章Elements of Statistical Learning 読み会 第2章
Elements of Statistical Learning 読み会 第2章Tsuyoshi Sakama
 
Math533 finalexamreviewapr13
Math533 finalexamreviewapr13Math533 finalexamreviewapr13
Math533 finalexamreviewapr13Brent Heard
 
Contactless Calipper - English
Contactless Calipper - EnglishContactless Calipper - English
Contactless Calipper - EnglishGiga Khizanishvili
 
1006 formulas and geom
1006 formulas and geom1006 formulas and geom
1006 formulas and geomjbianco9910
 
TechMathII - 1.6 - Matrices
TechMathII - 1.6 - MatricesTechMathII - 1.6 - Matrices
TechMathII - 1.6 - Matriceslmrhodes
 

What's hot (18)

MCA_UNIT-1_Computer Oriented Numerical Statistical Methods
MCA_UNIT-1_Computer Oriented Numerical Statistical MethodsMCA_UNIT-1_Computer Oriented Numerical Statistical Methods
MCA_UNIT-1_Computer Oriented Numerical Statistical Methods
 
Adomian decomposition Method and Differential Transform Method to solve the H...
Adomian decomposition Method and Differential Transform Method to solve the H...Adomian decomposition Method and Differential Transform Method to solve the H...
Adomian decomposition Method and Differential Transform Method to solve the H...
 
Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...
Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...
Chebyshev Collocation Approach for a Continuous Formulation of Implicit Hybri...
 
Q0749397
Q0749397Q0749397
Q0749397
 
MCA_UNIT-2_Computer Oriented Numerical Statistical Methods
MCA_UNIT-2_Computer Oriented Numerical Statistical MethodsMCA_UNIT-2_Computer Oriented Numerical Statistical Methods
MCA_UNIT-2_Computer Oriented Numerical Statistical Methods
 
Scrodinger wave equation
Scrodinger wave equationScrodinger wave equation
Scrodinger wave equation
 
Direct and indirect methods
Direct and indirect methodsDirect and indirect methods
Direct and indirect methods
 
Definition of statistical efficiency
Definition of statistical efficiencyDefinition of statistical efficiency
Definition of statistical efficiency
 
Top schools in noida
Top schools in noidaTop schools in noida
Top schools in noida
 
Course pack unit 5
Course pack unit 5Course pack unit 5
Course pack unit 5
 
Fixed point Iterative Method
Fixed point Iterative MethodFixed point Iterative Method
Fixed point Iterative Method
 
Measures of Central tendency
Measures of Central tendencyMeasures of Central tendency
Measures of Central tendency
 
Elements of Statistical Learning 読み会 第2章
Elements of Statistical Learning 読み会 第2章Elements of Statistical Learning 読み会 第2章
Elements of Statistical Learning 読み会 第2章
 
Math533 finalexamreviewapr13
Math533 finalexamreviewapr13Math533 finalexamreviewapr13
Math533 finalexamreviewapr13
 
Curve fitting
Curve fittingCurve fitting
Curve fitting
 
Contactless Calipper - English
Contactless Calipper - EnglishContactless Calipper - English
Contactless Calipper - English
 
1006 formulas and geom
1006 formulas and geom1006 formulas and geom
1006 formulas and geom
 
TechMathII - 1.6 - Matrices
TechMathII - 1.6 - MatricesTechMathII - 1.6 - Matrices
TechMathII - 1.6 - Matrices
 

Viewers also liked

Coneixer barcelona(15 16). ppt
Coneixer barcelona(15 16). pptConeixer barcelona(15 16). ppt
Coneixer barcelona(15 16). pptmvilage
 
รูปพื้นที่ผิว
รูปพื้นที่ผิวรูปพื้นที่ผิว
รูปพื้นที่ผิวKrueed Huaybong
 
Prematuridad y bajo peso al nacer
Prematuridad y bajo peso al nacerPrematuridad y bajo peso al nacer
Prematuridad y bajo peso al nacerAntonio Fernandez
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented PrinciplesSujit Majety
 
5 jobs where bots will replace humans
5 jobs where bots will replace humans5 jobs where bots will replace humans
5 jobs where bots will replace humansSoftweb Solutions
 
The Most effective models for Customer Support Operations
The Most effective models for Customer Support OperationsThe Most effective models for Customer Support Operations
The Most effective models for Customer Support OperationsDavid Loia
 
Expo condiciones imagen
Expo condiciones imagenExpo condiciones imagen
Expo condiciones imagenJose Joubran
 
Verden lige nu
Verden lige nuVerden lige nu
Verden lige nupersloth
 
Arquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e CenáriosArquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e Cenáriosposgraduacaorj
 
Dossier prensa COTIF 2016
Dossier prensa COTIF 2016Dossier prensa COTIF 2016
Dossier prensa COTIF 2016Alba Obscura
 
Introduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDBIntroduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDBBehrouz Bakhtiari
 

Viewers also liked (20)

Coneixer barcelona(15 16). ppt
Coneixer barcelona(15 16). pptConeixer barcelona(15 16). ppt
Coneixer barcelona(15 16). ppt
 
Transfer Printable fabrics Silhouette Cameo 2
Transfer Printable fabrics Silhouette Cameo 2Transfer Printable fabrics Silhouette Cameo 2
Transfer Printable fabrics Silhouette Cameo 2
 
รูปพื้นที่ผิว
รูปพื้นที่ผิวรูปพื้นที่ผิว
รูปพื้นที่ผิว
 
Tech coach flyer
Tech coach flyerTech coach flyer
Tech coach flyer
 
Prematuridad y bajo peso al nacer
Prematuridad y bajo peso al nacerPrematuridad y bajo peso al nacer
Prematuridad y bajo peso al nacer
 
filosofias de la calidad
filosofias de la calidadfilosofias de la calidad
filosofias de la calidad
 
Curso deferias
Curso deferiasCurso deferias
Curso deferias
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Arquitetura de informação
Arquitetura de informaçãoArquitetura de informação
Arquitetura de informação
 
5 jobs where bots will replace humans
5 jobs where bots will replace humans5 jobs where bots will replace humans
5 jobs where bots will replace humans
 
The Most effective models for Customer Support Operations
The Most effective models for Customer Support OperationsThe Most effective models for Customer Support Operations
The Most effective models for Customer Support Operations
 
Expo condiciones imagen
Expo condiciones imagenExpo condiciones imagen
Expo condiciones imagen
 
MEI
MEIMEI
MEI
 
ไอโซเมอร์
ไอโซเมอร์ไอโซเมอร์
ไอโซเมอร์
 
Verden lige nu
Verden lige nuVerden lige nu
Verden lige nu
 
Webwriting That Works
Webwriting That WorksWebwriting That Works
Webwriting That Works
 
Arquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e CenáriosArquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e Cenários
 
Dossier prensa COTIF 2016
Dossier prensa COTIF 2016Dossier prensa COTIF 2016
Dossier prensa COTIF 2016
 
Introduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDBIntroduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDB
 
Superlative
SuperlativeSuperlative
Superlative
 

Similar to 06 regression

08 numerical integration
08 numerical integration08 numerical integration
08 numerical integrationMohammad Tawfik
 
08 interpolation lagrange
08 interpolation   lagrange08 interpolation   lagrange
08 interpolation lagrangeMohammad Tawfik
 
09 numerical integration
09 numerical integration09 numerical integration
09 numerical integrationMohammad Tawfik
 
08 numerical integration 2
08 numerical integration 208 numerical integration 2
08 numerical integration 2Mohammad Tawfik
 
11 initial value problems system
11 initial value problems   system11 initial value problems   system
11 initial value problems systemMohammad Tawfik
 
12 boundary value problem
12 boundary value problem12 boundary value problem
12 boundary value problemMohammad Tawfik
 
FFT and DFT algorithm
FFT and DFT algorithmFFT and DFT algorithm
FFT and DFT algorithmUmer Javed
 

Similar to 06 regression (9)

08 numerical integration
08 numerical integration08 numerical integration
08 numerical integration
 
08 interpolation lagrange
08 interpolation   lagrange08 interpolation   lagrange
08 interpolation lagrange
 
09 numerical integration
09 numerical integration09 numerical integration
09 numerical integration
 
03 open methods
03 open methods03 open methods
03 open methods
 
08 numerical integration 2
08 numerical integration 208 numerical integration 2
08 numerical integration 2
 
11 initial value problems system
11 initial value problems   system11 initial value problems   system
11 initial value problems system
 
12 boundary value problem
12 boundary value problem12 boundary value problem
12 boundary value problem
 
FFT and DFT algorithm
FFT and DFT algorithmFFT and DFT algorithm
FFT and DFT algorithm
 
Central Tendancy.pdf
Central Tendancy.pdfCentral Tendancy.pdf
Central Tendancy.pdf
 

More from Mohammad Tawfik

Supply Chain Management for Engineers - INDE073
Supply Chain Management for Engineers - INDE073Supply Chain Management for Engineers - INDE073
Supply Chain Management for Engineers - INDE073Mohammad Tawfik
 
Supply Chain Management 01 - Introduction
Supply Chain Management 01 - IntroductionSupply Chain Management 01 - Introduction
Supply Chain Management 01 - IntroductionMohammad Tawfik
 
Supply Chain Management 02 - Logistics
Supply Chain Management 02 - LogisticsSupply Chain Management 02 - Logistics
Supply Chain Management 02 - LogisticsMohammad Tawfik
 
Supply Chain Management 03 - Inventory Management
Supply Chain Management 03 - Inventory ManagementSupply Chain Management 03 - Inventory Management
Supply Chain Management 03 - Inventory ManagementMohammad Tawfik
 
Creative problem solving and decision making
Creative problem solving and decision makingCreative problem solving and decision making
Creative problem solving and decision makingMohammad Tawfik
 
Digital content for teaching introduction
Digital content for teaching introductionDigital content for teaching introduction
Digital content for teaching introductionMohammad Tawfik
 
Crisis Management Basics
Crisis Management BasicsCrisis Management Basics
Crisis Management BasicsMohammad Tawfik
 
Effective Delegation Skills
Effective Delegation SkillsEffective Delegation Skills
Effective Delegation SkillsMohammad Tawfik
 
Business Management - Marketing
Business Management - MarketingBusiness Management - Marketing
Business Management - MarketingMohammad Tawfik
 
Project Management (CAPM) - Integration
Project Management (CAPM) - IntegrationProject Management (CAPM) - Integration
Project Management (CAPM) - IntegrationMohammad Tawfik
 
Project Management (CAPM) - The Framework
Project Management (CAPM) - The FrameworkProject Management (CAPM) - The Framework
Project Management (CAPM) - The FrameworkMohammad Tawfik
 
Project Management (CAPM) - Introduction
Project Management (CAPM) - IntroductionProject Management (CAPM) - Introduction
Project Management (CAPM) - IntroductionMohammad Tawfik
 
Introduction to Wind Energy
Introduction to Wind EnergyIntroduction to Wind Energy
Introduction to Wind EnergyMohammad Tawfik
 
Finite Element for Trusses in 2-D
Finite Element for Trusses in 2-DFinite Element for Trusses in 2-D
Finite Element for Trusses in 2-DMohammad Tawfik
 

More from Mohammad Tawfik (20)

Supply Chain Management for Engineers - INDE073
Supply Chain Management for Engineers - INDE073Supply Chain Management for Engineers - INDE073
Supply Chain Management for Engineers - INDE073
 
Supply Chain Management 01 - Introduction
Supply Chain Management 01 - IntroductionSupply Chain Management 01 - Introduction
Supply Chain Management 01 - Introduction
 
Supply Chain Management 02 - Logistics
Supply Chain Management 02 - LogisticsSupply Chain Management 02 - Logistics
Supply Chain Management 02 - Logistics
 
Supply Chain Management 03 - Inventory Management
Supply Chain Management 03 - Inventory ManagementSupply Chain Management 03 - Inventory Management
Supply Chain Management 03 - Inventory Management
 
Creative problem solving and decision making
Creative problem solving and decision makingCreative problem solving and decision making
Creative problem solving and decision making
 
Digital content for teaching introduction
Digital content for teaching introductionDigital content for teaching introduction
Digital content for teaching introduction
 
Crisis Management Basics
Crisis Management BasicsCrisis Management Basics
Crisis Management Basics
 
DISC Personality Model
DISC Personality ModelDISC Personality Model
DISC Personality Model
 
Training of Trainers
Training of TrainersTraining of Trainers
Training of Trainers
 
Effective Delegation Skills
Effective Delegation SkillsEffective Delegation Skills
Effective Delegation Skills
 
Train The Trainer
Train The TrainerTrain The Trainer
Train The Trainer
 
Business Management - Marketing
Business Management - MarketingBusiness Management - Marketing
Business Management - Marketing
 
Stress Management
Stress ManagementStress Management
Stress Management
 
Project Management (CAPM) - Integration
Project Management (CAPM) - IntegrationProject Management (CAPM) - Integration
Project Management (CAPM) - Integration
 
Project Management (CAPM) - The Framework
Project Management (CAPM) - The FrameworkProject Management (CAPM) - The Framework
Project Management (CAPM) - The Framework
 
Project Management (CAPM) - Introduction
Project Management (CAPM) - IntroductionProject Management (CAPM) - Introduction
Project Management (CAPM) - Introduction
 
The Creative Individual
The Creative IndividualThe Creative Individual
The Creative Individual
 
Introduction to Wind Energy
Introduction to Wind EnergyIntroduction to Wind Energy
Introduction to Wind Energy
 
Finite Element for Trusses in 2-D
Finite Element for Trusses in 2-DFinite Element for Trusses in 2-D
Finite Element for Trusses in 2-D
 
Future of Drones ITW'16
Future of Drones ITW'16Future of Drones ITW'16
Future of Drones ITW'16
 

06 regression

  • 1. 1 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Regression/Curve Fitting ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Objectives • Understanding the difference between regression and interpolation • Knowing how to “best fit” a polynomial into a set of data • Knowing how to use a polynomial to interpolate data
  • 2. 2 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Measured Data ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Polynomial Fit!
  • 3. 3 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Line Fit! ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Which is better?
  • 4. 4 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Curve Fitting • If the data measured is of high accuracy and it is required to estimate the values of the function between the given points, then, polynomial interpolation is the best choice. • If the measurements are expected to be of low accuracy, or the number of measured points is too large, regression would be the best choice. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Regression
  • 5. 5 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Why Regression? • Measurements that we get from real situations are not usually consistent! • The number of “pieces” of information that we can get about a certain project is HUGE • You can NEVER measure exact values! ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Measured Data
  • 6. 6 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik But, how to get the equation of a line that is “good” for all the data you have! ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Equation of a Line: Revision xaay 10 += If you have two points 1101 xaay += 2102 xaay +=       =             2 1 1 0 2 1 1 1 y y a a x x
  • 7. 7 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solving for the constants! 12 12 1 12 2112 0 & xx yy a xx yxyx a − − = − − = ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik What if I have more than two points?
  • 8. 8 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik For every point nn xaay xaay xaay 10 2102 1101 +≠ +≠ +≠ M                   ≠               1 02 1 2 1 1 1 1 a a x x x y y y nn MMM ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik So, we may write the error vector                   −               =               1 02 1 2 1 2 1 1 1 1 a a x x x y y y e e e nnn MMMM { } { } [ ] { } 1*22*1*1* aAye nnn −=
  • 9. 9 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Square the error { } { } [ ]{ }aAye −= { } { } { } { } { } [ ]{ } { } [ ] { } { } [ ] [ ]{ } 2 eaAAayAa aAyyyee TTTT TTT =+− −= ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Note: this is a scalar equation! { } { } { } { } { } [ ]{ } { } [ ] { } { } [ ] [ ]{ } 2 eaAAayAa aAyyyee TTTT TTT =+− −= { } [ ]{ } { } [ ] { }yAaaAy TTT = { } { } { } [ ] { } { } [ ] [ ]{ }aAAayAayye TTTTT +−= 2 2
  • 10. 10 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Note: this is a quadratic equation in {a}!!! { } { } { } [ ] { } { } [ ] [ ]{ }aAAayAayye TTTTT +−= 2 2 To minimize the error in the above equation, we need to differentiate with respect to the parameters { } [ ] { } [ ] [ ]{ } 022 2 =+−= aAAyA ad ed TT ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solving the equation We get: { } [ ] { } [ ] [ ]{ } 022 2 =+−= aAAyA ad ed TT [ ] [ ] { } [ ] { } 1**21*22**2 n T nn T n yAaAA = [ ] { } { } 1*21*22*2 yaA = { } [ ] { }yAa 1− =
  • 11. 11 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Example • If you are given the data. • Find the equation of the “best-fit” line. y=a1+a2x 5.57 66 3.55 44 23 2.52 0.51 yx ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution                       =                             5.5 6 5.3 4 2 5.2 5.0 71 61 51 41 31 21 11 1 0 a a [ ] { }                       =                       = 5.5 6 5.3 4 2 5.2 5.0 & 71 61 51 41 31 21 11 yA
  • 12. 12 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution [ ] [ ]       =                             = 14028 287 71 61 51 41 31 21 11 7654321 1111111 AA T ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution [ ] { }       =                             = 5.119 24 5.5 6 5.3 4 2 5.2 5.0 7654321 1111111 yA T
  • 13. 13 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution       =             5.119 24 14028 287 1 0 a a [ ] [ ]{ } [ ] { }yAaAA TT =       =       8393.0 0714.0 1 0 a a 0714.08393.0 += xy ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Example • If you are given the data. • Find the equation of the “best-fit” parabola. y=a0+a1x+a2x2 5.57 66 3.55 44 23 2.52 0.51 yx
  • 14. 14 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution                       =                                 5.5 6 5.3 4 2 5.2 5.0 49 36 25 16 9 4 1 71 61 51 41 31 21 11 2 1 0 a a a [ ] { }                       =                       = 5.5 6 5.3 4 2 5.2 5.0 & 49 36 25 16 9 4 1 71 61 51 41 31 21 11 yA ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution [ ] [ ]           =                                 = 4676784140 78414028 140287 49 36 25 16 9 4 1 71 61 51 41 31 21 11 49362516941 7654321 1111111 AA T
  • 15. 15 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution [ ] { }           =                                 = 5.665 5.119 24 5.5 6 5.3 4 2 5.2 5.0 49362516941 7654321 1111111 yA T ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution [ ] [ ]{ } [ ] { }yAaAA TT =           − − =           0298.0 0774.1 2857.0 2 1 0 a a a 2857.00774.10298.0 2 −+−= xxy
  • 16. 16 ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Homework #4 • Chapter 17, pp. 471-472, numbers: 17.4,17.5. • Use the data and regression to get the equation of the line that best fits the data • Number 17.7 • Use the data and regression to get the equation of the line and the parabola that best fit the data