You are on page 1of 16

PROBABILITY AND

STATISTICS
CURVE FITTING
CURVE FITTING
Curve Fitting
The process of finding the equation of the curve which best fits the given values and most
suitable for predicting the unknown values is known as Curve Fitting.

The method which we use here for finding curve fitting is the method of least square.

There wish to describe a certain type of function that best expresses association that exists
between variables. Scatter plot of the set of values of the variables make it possible to visualize a
smooth curve that effectively approximates the given data set.

A more useful way to represent this sort of approximating curve is by means of an equation or a
formula. The terms applied to the process of determining the equation and/or estimating the
parameters appearing in the equation of approximating curve, is commonly called Curve Fitting.
LEAST SQUARE METHOD
Least Square Method
Following are the different method of Least Square:

1. Equation of Line
(𝑦 = 𝑎𝑥 + 𝑏 or 𝑦 = 𝑎 + 𝑏𝑥)

2. Equation of Parabola or 2nd order polynomial (Quadratic curve)


(𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 )

3. Exponential Curve
(𝑦 = 𝑎𝑋 𝑏 , 𝑦 = 𝑎𝑏 𝑥 or 𝑦 = 𝑎𝑒 𝑏𝑥 )
EQUATION OF LINE
1. Equation of Line

Line to be fitted for the data y = a + bx where a and b need to be calculated. We have the normal
equation for the least square straight line is:

The normal equation for the finding a and b are:


EQUATION OF LINE
2
𝑦 = 𝑛𝑎 + 𝑏 𝑥 and 𝑥𝑦 = 𝑎 𝑥+𝑏 𝑥
The equation for required straight line will be;
𝑦𝑖 = 𝑎 + 𝑏𝑥𝑖
Then the error between the actual vertical point 𝑦𝑖 and the fitted point is given by;
𝑒𝑖 = 𝑦𝑖 − 𝑦𝑖
If we have to calculate error then calculate with every equation
𝑒𝑖 → minimum → best fit
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
EQUATION OF LINE
Solution:
Let the equation of the straight line to be fitted to the data, be y = a + bx where a and b are to be
evaluated.
The normal equations for determining a and b are;
2
𝑦 = 𝑛𝑎 + 𝑏 𝑥 and 𝑥𝑦 = 𝑎 𝑥 + 𝑏 𝑥
𝑥 𝑦 𝑥2 𝑦2 𝑥𝑦
Normal equations becomes;
1 3 1 9 3
2 4 4 16 8
5a + 15b = 32
3 6 9 36 18 15a + 55b = 115
4 9 16 81 36 Solving these equations: a = 0.7, b = 1.9
5 10 25 100 50
Hence the equation of the required straight line is;
15 32 55 242 115
𝒚 = 𝟎. 𝟕 + 𝟏. 𝟗𝒙
EQUATION OF LINE
For finding error

𝒚 = 𝟎. 𝟕 + 𝟏. 𝟗𝒙 𝒆𝒊 = 𝒚𝒊 − 𝒚
𝟎. 𝟕 + 𝟏. 𝟗 𝟏 = 𝟐. 𝟔 3 − 2.6 = 0.4
𝟎. 𝟕 + 𝟏. 𝟗 𝟐 = 𝟒. 𝟓 4 − 4.5 = −0.5
𝟎. 𝟕 + 𝟏. 𝟗 𝟑 = 𝟔. 𝟒 6 − 6.4 = −0.4
𝟎. 𝟕 + 𝟏. 𝟗 𝟒 = 𝟖. 𝟑 9 − 8.3 = 0.7
𝟎. 𝟕 + 𝟏. 𝟗 𝟓 = 𝟏𝟎. 𝟐 10 − 10.2 = −0.2
𝑒𝑖 =0
FITTING A SECOND DEGREE PARABOLA
2. Fitting A Second Degree Parabola
The simplest type of a non-linear approximating curve is the second degree parabola that
has the equation.
𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2
Where the values of a, b and c to be determined by;
2 3
𝑦 = 𝑛𝑎 + 𝑏 𝑥 + 𝑐 𝑥 2 , 𝑥𝑦 = 𝑎 𝑥 + 𝑏 𝑥 + 𝑐 𝑥 and
3 4
𝑥 2𝑦 = 𝑎 𝑥2 + 𝑏 𝑥 +𝑐 𝑥

Error is given as: 𝑒𝑖 = 𝑦𝑖 − 𝑦𝑖 where 𝑦𝑖 = actual line and 𝑦𝑖 = approximate line


FITTING A SECOND DEGREE PARABOLA
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 3
𝑦 = 𝑛𝑎 + 𝑏 𝑥 + 𝑐 𝑥2, 𝑥𝑦 = 𝑎 𝑥+𝑏 𝑥 +𝑐 𝑥 and
3 4
𝑥 2𝑦 = 𝑎 𝑥2 + 𝑏 𝑥 +𝑐 𝑥
FITTING A SECOND DEGREE PARABOLA
𝑥 𝑦 𝑥𝑦 𝑥2 𝑥2𝑦 𝑥3 𝑥4 putting the values in the normal equations
0 1 0 0 0 0 0 we get;
1 1.8 1.8 1 1.8 1 1
2 1.3 2.6 4 5.2 8 16 12.9 = 5a + 10b + 30c
3 2.5 7.5 9 22.5 27 81 37.1 = 10a + 30b + 100c
4 6.3 25.2 16 100.8 64 256
130.3 = 30a + 100b + 354c
10 12.9 37.1 30 130.3 100 354

Solving simultaneously we obtain;


a = 1.42, b = -1.07 and c = 0.55

Hence the required second degree parabola equation is;


𝒚 = 𝟏. 𝟒𝟐 − 𝟏. 𝟎𝟕𝒙 + 𝟎. 𝟓𝟓𝒙𝟐
EXPONENTIAL CURVE
3. Exponential Curve

Example:
Find the equation of the curve 𝑦 = 𝑎𝑏 𝑥 that best fits the following data and find y(10).
𝑥 3 4 5 6 7 8 9

𝑦 11 12 14 18 19 21 23

Solution:
Since 𝑦 = 𝑎𝑏 𝑥
Therefore 𝑙𝑛𝑦 = 𝑙𝑛𝑎 + 𝑥𝑙𝑛𝑏
Let 𝑙𝑛𝑦 = 𝑌, 𝑙𝑛𝑎 = 𝐴 and 𝑙𝑛𝑏 = 𝐵
Now 𝑌 = 𝐴 + 𝐵𝑥
2
Which is now in linear form: 𝑌 = 𝑛𝐴 + 𝐵 𝑥 and 𝑥𝑌 = 𝐴 𝑥+𝐵 𝑥
EXPONENTIAL CURVE
𝑥 𝑦 𝑌 = 𝑙𝑛𝑦 𝑥𝑌 𝑥2 7A + 42B = 19.5
3 11 2.39 7.17 9 42A + 280B = 120.65
4 12 2.48 9.92 16 B = 0.130, A = 2.003
5 14 2.63 13.5 25
6 18 2.89 17.34 36
7 19 2.94 20.58 49 Now,
8 21 3.04 24.32 64
9 23 3.13 28.17 81
𝐴 = 𝑙𝑛 𝑎 𝐵 = 𝑙𝑛 𝑏
𝑒𝐴 = 𝑎 𝑒𝐵 = 𝑏
42 118 19.5 120.65 280
𝑒 2.003 = 𝑎 𝑒 0.130 = 𝑏
a = 7.411 b = 1.138
𝒚 = 7.47446(1.138)𝑥 = 7.411(1.138)10

𝒚 = 𝟐𝟔. 𝟗𝟗
EXPONENTIAL CURVE
Example:
Determine the constant a and b by the method of least square such that 𝑦 = 𝑎𝑒 𝑏𝑥 to the
following data:
𝑥 2 4 6 8 10

𝑦 4.077 11.084 30.128 81.897 222.62

Solution:
The given relation is: 𝑦 = 𝑎𝑒 𝑏𝑥
Therefore 𝑙𝑛𝑦 = 𝑙𝑛𝑎 + 𝑏𝑥
Let 𝑙𝑛𝑦 = 𝑌 and 𝑙𝑛𝑎 = 𝐴
Now 𝑌 = 𝐴 + 𝑏𝑥
2
Which is now in linear form: 𝑌 = 𝑛𝐴 + 𝑏 𝑥 and 𝑥𝑌 = 𝐴 𝑥+𝑏 𝑥
EXPONENTIAL CURVE
𝑥 𝑦 𝑌 = 𝑙𝑛𝑦 𝑥𝑌 𝑥2 17.023 = 5A + 30b
2 4.077 1.405 2.810 4 122.146 = 30A + 220b
4 11.084 2.405 9.620 16 A = 0.403, b = 0.5
6 30.128 3.405 20.430 36
8 81.897 4.405 35.240 64
10 222.62 5.405 54.050 100 Now,
30 349.806 17.023 122.146 220 𝐴 = 𝑙𝑛 𝑎 𝑏 = 0.5
𝑒𝐴 = 𝑎
𝑒 0.403 = 𝑎
a = 1.496 b = 0.5

Now
𝒚 = 𝟏. 𝟒𝟗𝟔𝒆𝟎.𝟓𝒙
EXPONENTIAL CURVES
Example:
Fit an equation of the form 𝑌 = 𝑎𝑋 𝑏 to the following data:
𝑋 1 2 3 4 5 6

𝑌 2.98 4.26 5.21 6.10 6.80 7.50

Solution:
We may reduce the given equation to a linear form by taking logs to the base 10. Thus
𝑙𝑛 𝑌 = 𝑙𝑛 𝑎 + 𝑏 𝑙𝑛 𝑋
Or 𝑌 ′ = 𝐴 + 𝑏𝑋 ′
Where 𝑌 ′ = 𝑙𝑛 𝑌, 𝐴 = 𝑙𝑛 𝑎 and 𝑋 ′ = 𝑙𝑛 𝑋

As the equation is linear in 𝑌 ′ = 𝑙𝑛 𝑌 and 𝑋 ′ = 𝑙𝑛 𝑋, therefore the two normal equations are;
EXPONENTIAL CURVES
𝑌 ′ = 𝑛𝐴 + 𝑏 𝑋′
2
𝑋 ′𝑌′ = 𝐴 𝑋′ + 𝑏 𝑋′

The following table contains the necessary calculations:


2 Normal equations becomes;
𝑋 𝑋′ = 𝑙𝑛 𝑋 𝑌 𝑌 ′ = 𝑙𝑛 𝑌 𝑋′ 𝑌′ 𝑋′
6A + 2.8574b = 4.3133
1 0 2.98 0.4742 0 0
2 0.3010 4.26 0.6294 0.189449 0.0906 2.8574A + 1.7749b = 2.2672
3 0.4771 5.21 0.7168 0.341986 0.2276 Solving these equations: a = 2.978,
4 0.6021 6.10 0.7853 0.472829 0.3625 b = 0.5144
5 0.6990 6.80 0.8325 0.581918 0.4886
6 0.7782 7.50 0.8751 0.681003 0.6056
Σ 2.8574 --- 4.3133 2.267185 1.7749
Hence the equation of the required form is;
𝒀 = 𝟐. 𝟗𝟕𝟖(𝑿)𝟎.𝟓𝟏𝟒𝟒
𝒀 = 𝟑𝑿𝟏 𝟐 approximately.

You might also like