Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Presenter: Ms.

Sidra Raees

LECTURE 05
Department of Mathematics, NED University of
Engineering & Technology, Karachi

1
 Curve fitting is the process of constructing a curve, or
mathematical functions, which possess closest proximity to the
series of data. By the curve fitting we can mathematically
construct the functional relationship between the observed fact
and parameter values, etc. It is highly effective in
mathematical modeling some natural processes.
 It is a statistical technique use to drive coefficient values for
equations that express the value of one (dependent) variable as
a function of another (independent variable).

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
2
The main purpose of curve fitting is to theoretically
describe experimental data with a model (function or
equation) and to find the parameters associated with this
model.

The method which we use here for finding curve fitting is


Method of Least Squares.

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
3
1. Equation of straight line
𝑦 = 𝑎 + 𝑏𝑥

2. Equation of parabola or second order polynomial or


Quadratic curve
𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2

3. Exponential curve
𝑦 = 𝑎𝑏 𝑥 or 𝑦 = 𝑎𝑒 𝑏𝑥

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
4
A line to be fitted for the data
𝑦 = 𝑎 + 𝑏𝑥, where a and b needs
to be calculated.

The normal equations for determining


a and b are:

σ 𝑦 = 𝑛𝑎 + 𝑏 σ 𝑥
σ 𝑥𝑦 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2

The equation for required straight line


Will be
𝑦ෝ𝑖 = 𝑎 + 𝑏𝑥𝑖
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
5
Then the error between the actual vertical points 𝑦𝑖 and
the fitted points 𝑦ෝ𝑖 is given by

2
Σ𝑒𝑖 = Σ 𝑦𝑖 − 𝑦ෝ𝑖

σ 𝑒𝑖 Minimum best fit

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
6
Example
Fit a straight line by the method of least squares to the
following data:
𝒙 1 2 3 4 5
𝑦 3 4 6 9 10

Solution:
Let the equation of the straight line to be fitted to the
data, be 𝑦 = 𝑎 + 𝑏𝑥, where a and b are to be evaluated.
The normal equations for determining a and b are
σ 𝑦 = 𝑛𝑎 + 𝑏 σ 𝑥
σ 𝑥𝑦 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
7
𝒙 𝒚 𝒙𝒚 𝒙𝟐
1 3 3 1
2 4 8 4
3 6 18 9
4 9 36 16
5 10 50 25
σ 𝑥 = 15 σ 𝑦 = 32 σ 𝑥𝑦 = 115 σ 𝑥 2 = 55

Now normal equations become


5𝑎 + 15𝑏 = 32
15𝑎 + 55𝑏 = 115
Solving these equations
𝑎 = 0.7, 𝑏 = 1.9
Hence, the equation of the required straight line is
𝑦ො = 0.7 + 1.9𝑥
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
8
Q. Calculate error for previous example.

For finding error


𝒙 𝒚 ෝ = 𝟎. 𝟕 + 𝟏. 𝟗𝒙
𝒚 ෝ
𝒆= 𝒚−𝒚 𝟐

1 3 2.6 0.16
2 4 4.5 0.25
3 6 6.4 0.16
4 9 8.3 0.49
5 10 10.2 0.04
Σ𝑒 = Σ 𝑦 − 𝑦ො 2 = 1.1

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
The Simplest type of a non-linear approximating curve is the
second degree parabola that has the equation
𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 ,

Where the values a, b and c to be determined by

σ 𝑦 = 𝑛𝑎 + 𝑏 σ 𝑥 + 𝑐 σ 𝑥 2
σ 𝑥𝑦 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2 + 𝑐 σ 𝑥 3
σ 𝑥2𝑦 = 𝑎 σ 𝑥2 + 𝑏 σ 𝑥3 + 𝑐 σ 𝑥4

Error:
2
Σ𝑒𝑖 = Σ 𝑦𝑖 − 𝑦ෝ𝑖
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
10
Example
Fit a second degree parabola to the following data:
𝒙 0 1 2 3 4
𝑦 1 1.8 1.3 2.5 6.3

Solution:
Let the equation of the second degree parabola be
𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2
The normal equations are
σ 𝑦 = 𝑛𝑎 + 𝑏 σ 𝑥 + 𝑐 σ 𝑥 2
σ 𝑥𝑦 = 𝑎 σ 𝑥 + 𝑏 σ 𝑥 2 + 𝑐 σ 𝑥 3
σ 𝑥 2𝑦 = 𝑎 σ 𝑥 2 + 𝑏 σ 𝑥 3 + 𝑐 σ 𝑥 4
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
11
𝒙 𝒚 𝒙𝒚 𝒙𝟐 𝒙𝟐 𝒚 𝒙𝟑 𝒙𝟒
0 1 0 0 0 0 0
1 1.8 1.8 1 1.8 1 1
2 1.3 2.6 4 5.2 8 16
3 2.5 7.5 9 22.5 27 81
4 6.3 25.2 16 100.8 64 256
10 12.9 37.1 30 130.3 100 354

Now the normal equations become


5𝑎 + 10𝑏 + 30𝑐 = 12.9
10𝑎 + 30𝑏 + 100𝑐 = 37.1
30𝑎 + 100𝑏 + 354𝑐 = 130.3
Solving simultaneously, we get
𝑎 = 1.42, 𝑏 = −1.07, 𝑐 = 0.55
Hence, the required second degree parabola equation is
𝑦ො = 1.42 − 1.07𝑥 + 0.55𝑥 2
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
12
Example
Find the equation of the curve 𝑦 = 𝑎𝑏 𝑥 , that best fits the
following data. And find 𝑦 10 .
𝒙 3 4 5 6 7 8 9
𝑦 11 12 14 18 19 21 23

Solution:
The given relation is
𝑦 = 𝑎𝑏 𝑥
Taking 𝑙𝑛 on both sides
𝑙𝑛𝑦 = 𝑙𝑛𝑎 + 𝑥𝑙𝑛𝑏
Probability & Statistics (MT-331), Sidra Raees
Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
13
Taking
𝑌 = 𝑙𝑛𝑦, 𝐴 = 𝑙𝑛𝑎, 𝐵 = 𝑙𝑛𝑏
So,
𝑙𝑛𝑦 = 𝑙𝑛𝑎 + 𝑥𝑙𝑛𝑏

𝑌 = 𝐴 + 𝑥𝐵

Which is now in linear form.

σ 𝑌 = 𝑛𝐴 + 𝐵 σ 𝑥
σ 𝑥𝑌 = 𝐴 σ 𝑥 + 𝐵 σ 𝑥 2

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
14
𝒙 𝒚 𝒀 = 𝒍𝒏𝒚 𝒙𝐘 𝒙𝟐
3 11 2.3978 7.1934 9
4 12 2.4849 9.9396 16
5 14 2.6390 13.195 25
6 18 2.8903 17.3418 36
7 19 2.9444 20.6108 49
8 21 3.0445 24.356 64
9 23 3.1354 28.2186 81
σ 𝑥 = 42 σ 𝑦 = 118 σ 𝑌 = 19.5359 σ 𝑥𝑌 = 120.8552 σ 𝑥 2 = 280

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
15
Now,
𝐴 = 𝑙𝑛𝑎, 𝐵 = 𝑙𝑛𝑏
𝑒𝐴 = 𝑎 𝑒𝐵 = 𝑏
𝑒 2.01088 = 𝑎 𝑒 0.12999 = 𝑏
𝑎 = 7.4698 𝑏 =1.1388

Hence the required equation of the curve is

𝑦ො = 7.4698(1.1388)𝑥

𝑦(10) = 7.4698(1.1388)10 = 27.4020

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
16
Example
Determine the constants a and b by the method of least
square such that 𝑦 = 𝑎𝑒 𝑏𝑥
𝒙 2 4 6 8 10
𝑦 4.077 11.084 30.128 81.897 222.62

Solution:
The given relation is
𝑦 = 𝑎𝑒 𝑏𝑥
Taking 𝑙𝑛 on both sides
𝑙𝑛𝑦 = 𝑙𝑛𝑎 + 𝑏𝑥

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
17
Taking
𝑌 = 𝑙𝑛𝑦, 𝐴 = 𝑙𝑛𝑎
So,
𝑙𝑛𝑦 = 𝑙𝑛𝑎 + 𝑏𝑥

𝑌 = 𝐴 + 𝑏𝑥

Which is now in linear form.

σ 𝑌 = 𝑛𝐴 + 𝑏 σ 𝑥
σ 𝑥𝑌 = 𝐴 σ 𝑥 + 𝑏 σ 𝑥 2

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
18
𝒙 𝒚 𝒀 = 𝒍𝒏𝒚 𝒙𝐘 𝒙𝟐
2 4.077 1.4054 2.8108 4
4 11.084 2.4055 9.622 16
6 30.128 3.4054 20.4324 36
8 181.897 5.2034 41.6272 64
10 222.62 5.4054 54.054 100

σ 𝑥 = 30 σ 𝑦 = 449.806 σ 𝑌 = 17.8251 σ 𝑥𝑌 = 128.5464 σ 𝑥 2 = 220

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
19
Now,
𝐴 = 𝑙𝑛𝑎
𝑒𝐴 = 𝑎
𝑎 = 𝑒 0.3256
𝑎 = 1.3848

Hence the required equation of the curve is

𝑦ො = 1.3848𝑒 0.539𝑥

Probability & Statistics (MT-331), Sidra Raees


Copyrights Protected-Department of Mathematics, NED University of Engineering & Technology, Karachi
20

You might also like