Bmate301 Module 2
Bmate301 Module 2
➢ A
Curve Fitting: Curve fitting by the method of least squares- fitting the curves of the form-
D
y = ax+ b , y = a𝐱𝟐+ bx + c, y = a𝐞𝐛𝐱, y=a𝒙𝒃
AD
U
VT
Introduction
Correlation
So far, while explain measures of central tendency as well as measures of dispersion, one do
the analysis of observations on a single variable or univariate say x.
There are many phenomena where the changes in one variable are related to the changes in
the other variable. Suppose two variables x and y are related in such a way that an increase in
one is accompanied by an increase or decrease in the other. Such a relationship is called
Change in one variable followed by change in other variable is called correlation or
covariation
Positive Correlation
A positive correlation is a relationship between two variables where if one variable
increases( or decreases), the other one also increases(or decreases)
Example
A
D
Demand and price of a commodity are positively correlated as increase in one
results in increase in the other or vice versa.
AD
Example
Examples:
A
D
∑1𝑛(𝑥− 𝑥)(𝑦− 𝑦)
r= … (1)
AD
𝑛𝜎𝑥𝜎𝑦
√∑ 𝑋2 ∑ 𝑌2
Property :
Note : If r = ± 1 we say that x and y are perfectly correlated and if r = 0 we say that x
and y are non correlated.
1. Calculate the karl – pearson co – efficient for the following ages of husband
and wife’s.
Roll No. 1 2 3 4 5 6 7 8 9 10
Husband’s age (x) 36 23 27 28 28 29 30 31 33 35
Wife’s age (y) 29 18 20 22 27 21 29 27 29 28
∑𝑋 300 ∑𝑌
Soln: 𝑥 = = = 30 𝑦= = 250 = 25 Here n = 10
10 10 10 10
x y X= x - 𝑥 Y = y -𝑦 XY X2 Y2
36 29 -7 -7 49 49 49
23 18 -3 -5 15 9 25
27 20 -2 -3 6 4 9
28
28
22
27
-2
-1
2
-4
A -4
4
4
1
4
16
D
29 21 0 4 0 0 16
30 29 1 2 2 1 4
AD
31 27 3 4 12 9 16
33 29 5 3 15 25 9
35 28 6 4 24 36 16
U
∑𝑥 ∑𝑦 ∑ 𝑋𝑌 ∑ 𝑋2 ∑ 𝑌2
VT
It is a positive correlation.
x 10 14 18 22 26 30
y 18 12 24 6 30 36
∑ 𝑋𝑌
Soln. We have r= where X = x - 𝑥 , Y = y -𝑦
√∑ 𝑋2 ∑ 𝑌2
Here n = 6
∑𝑋 120 ∑𝑌
𝑥 = = = 20 𝑦= = 126 = 21
10 6 10 6
x y X= x -𝑥 Y = y-𝑦 XY X2 Y2
10 18 -10 -3 30 100 9
14 18 -6 -9 53 36 81
18 18 -2 3 -6 4 9
26 18 6 9
A 54 36 81
30 10 15
D 150 100 225
18
AD
∑𝑥 ∑𝑦 ∑ 𝑋𝑌 ∑ 𝑋2 ∑ 𝑌2
= 120 = 126 = 252 = 280 = 630
U
252
VT
We have r= = 0.6
√(280)(630)
It is a positive correlation.
3. Calculate Karl pearson co-efficient of correlation b/w the marks obtained by 8 students in
mathematics and statistics :
Statistics 8 10 15 17 20 23 24 25
Mathematics 25 30 32 35 37 40 42 45
∑ 𝑋𝑌
We have r= where X = x - 𝑥 , Y = y -𝑦
√∑ 𝑋2 ∑ 𝑌2
Here n = 8
∑𝑋 142 ∑𝑌
𝑥 = = = 17.75 𝑦= = 286 = 35.75
𝑛 8 𝑛 8
x y X= x - Y = y- XY X2 Y2
𝑥 𝑦
8 25 -9.75 -10.75 104.81 95.06 115.56
10 30 -7.75 -5.75 44.56 60.06 33.06
15 32 -2.75 -3.75 10.31 7.56 14.06
17 35 -0.75 -0.75 0.56 0.56 0.56
20 37 2.25 1.25 2.81 5.06 1.56
23 40 5.25 4.25 22.31 27.56 18.06
24 42 6.25 6.25 39.06 39.06 39.06
25 45 7.25
A
9.25 67.06 56.56 85.56
D
∑𝑥 ∑𝑦 ∑ 𝑋𝑌 ∑ 𝑋2 ∑ 𝑌2
= 17.75 = 35.75 = 291.4 = 291.480 = 307.48
AD
291.48
We have r= = 0.97
U
√(291.48)(307.48)
It is a positive correlation.
VT
Regression
Regression is an estimation of one independent variable in terms of the other. If x & y are
correlated, the best fitting straight line in the least square sense gives reasonably a good
relation between x & y.
The best fitting straight line of the form y = ax + b (x being the independent variable) is
called the regression line of y on x & x = ay + b (y being the independent variable) is called
the regression line of x on y.
Let y = ax + b be the equation of the regression line of y on x for a given set of n values (x,y).
𝜎𝑦
Then y- 𝑦= 𝑟 (x-𝑥)…..............(1)
𝜎𝑥
This is the regression of y on x.
Similarly,
𝜎𝑥
x- 𝑥 = 𝑟 (y-𝑦)… .......... (2)
𝜎𝑦
Thus we can conclude that r is the geometric mean (GM) of the regression coefficients since
the GM of two numbers a, b is √𝑎𝑏. That is
r = ±√(𝑐𝑜𝑒𝑓𝑓. 𝑜𝑓 𝑥)(𝑐𝑜𝑒𝑓𝑓. 𝑜𝑓 𝑦)
The sign of r will be positive or negative according as the regression coefficients are positive
or negative.
A
D
Note: The lines of regression (1) & (2) are also of the form
AD
∑ 𝑋𝑌 ∑ 𝑋𝑌
Y= (X) and X = (Y) Where X= x- 𝑥 & Y= y- 𝑦.
∑ 𝑋2 ∑ 𝑌2
This form will be useful to find out the coefficient of correction by first obtaining the lines of
U
r = ±√(𝑐𝑜𝑒𝑓𝑓. 𝑜𝑓 𝑥)(𝑐𝑜𝑒𝑓𝑓. 𝑜𝑓 𝑦)
Problems:
1. Compute the coefficient of correlation & the equation of the lines of regression for the
following data.
x 1 2 3 4 5 6 7
y 9 8 10 12 11 13 14
∑ 𝑋𝑌
Solu: We have coefficient of correlation r =
√∑𝑋 2 ∑𝑌 2
Where Y = y- 𝑦 X= x- 𝑥 Here n = 7
∑𝑥 ∑𝑦
𝑥 = = 28/7 = 4 𝑦= = 77/7 = 11
𝑛 𝑛
X y X= x- 𝑥 Y= y- 𝑦 XY 𝑋2 𝑌2
1 9 -3 -2 6 9 4
2 8 -2 -3 6 4 9
3 10 -1 -1 1 1 1
4 12 0 1 0 0 1
5 11 1 0 0 1 0
6 13 2 2 4 4 4
7 14 3 3 9 9 9
∑ 𝑥 = 28 ∑𝑦 ∑ 𝑋𝑌 = 26 ∑ 𝑋2=28 ∑ 𝑌2=28
= 77
2. Obtain the lines of regression and hence find the co-efficient of correlation for the
following data
x 1 3 4 2 5 8 9 10 13 15
U
y 8 6 10 8 12 16 16 10 32 32
Solution:
VT
∑𝑥 ∑𝑦
𝑥 = = 70/10 = 7 𝑦= = 150/10 =15
𝑛 𝑛
x y X= x- 𝑥 Y= y- 𝑦 xy 𝑋2 𝑌2
1 8 -6 -7 42 36 49
3 6 -4 -9 35 16 81
4 10 -3 -5 15 9 25
2 8 -5 -7 35 25 49
5 12 -2 -3 6 4 9
8 16 1 1 1 1 1
9 16 2 1 2 4 1
10 10 3 -5 -15 9 25
13 32 6 17 102 36 289
15 32 8 17 136 64 289
∑ 𝑥 = 10 ∑ 𝑦 = 150 ∑ 𝑋𝑌 = 360 ∑ 𝑋2 = 204 ∑ 𝑌2 = 818
Line of regression y on x line of regression x on y
∑ 𝑋𝑌 ∑ 𝑋𝑌
Y= .X X= .Y
∑ 𝑋2 ∑ 𝑌2
y = 1.764x-12.348+15
y = 1.764x + 2.652
A
2. Compute the coefficient of correlation & the equation of the lines of regression for the following
data.
D
x 10 14 18 22 26 30
AD
y 18 12 24 6 30 36
∑𝑥 120 ∑𝑦
Soln: 𝑥 = = = 20 𝑦= = 126 = 21
U
𝑛 6 𝑛 6
x y X= x- 𝑥 Y= y- 𝑦 XY 𝑋2 𝑌2
VT
10 18 -10 -3 30 100 9
14 12 -6 -9 54 36 81
18 24 -2 3 -6 4 9
22 6 2 -15 -30 4 225
26 30 6 9 54 36 81
30 36 10 15 150 100 225
∑𝑥 ∑𝑦 ∑ 𝑋𝑌 ∑ 𝑋2=280 ∑ 𝑌2=630
∑ 𝑋𝑌
We have, Coefficient of correlation r = = 0.6
√∑𝑋 2 ∑𝑌 2
Solu: W. K. T If is 𝜃 acute, the angle between the lines y = m1 x + c1 and y = m2 x +c2 is given by
𝑚 2− 𝑚 1
tan 𝜃 =
1+ 𝑚1 𝑚2
y - 𝑦= r
𝜎𝑦
( x - 𝑥) A
…. (1)
D
𝜎𝑥
AD
and ( x - 𝑥) = r 𝜎𝑥 (y - 𝑦)
𝜎𝑦
𝜎𝑦
We write the second of the equation as y - 𝑦= ( x - 𝑥) ….(2)
𝑟𝜎𝑥
U
𝜎𝑦 𝜎𝑦
m1 = r and m2 =
𝜎𝑥 𝑟𝜎𝑥
By solving we get 𝑥 = 13 𝑦= 17
We shall now rewrite the equation of the regression lines to find the regression
coefficients.
A
D
r = ± √(𝑐𝑜𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑥 )(𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑦) = ± √(0.8)(0.45) ,
AD
r = 0.6
It is a positive correlation
U
5 ) In a partially destroyed laboratory data, only the regression lines with equations
3𝑥 + 2𝑦 = 26, and
VT
6𝑥 + 𝑦 = 31 are available. Calculate the means of 𝑥′𝑠 , means of 𝑦′𝑠 and the
correlation co-efficient.
(−ve sign is taken since both the regressions coefficients are –ve)
Rank Correlation and an expression for the rank correlation coefficient.
6 ∑(𝑥−𝑦)2 ∑ 𝑑2
or 1 - 6
ρ =1-
𝑛 (𝑛2− 1) 𝑛 (𝑛2− 1)
Note:
(1) If the ranking of x ,y are entirely in the same order like for example, x :1 1,2,3,4,5 ; y :
1,2,3,4,5 then ∑ 𝑑2 = ∑(𝑥 − 𝑦 )2 = 0. This will give us 𝜌 = ± 1 and is called perfect
direct correlation.
If the ranking of x and y are entirely in the opposite order like for example, x :
1,2,3,4,5
A
y : 5,4,3,2,1 then ∑ 𝑑2 = [Link] will give us ρ = -1 and is called perfect inverse
D
correlation.
AD
Problems:
1. Ten competitors in a beauty contest are ranked by two judges in the following
order. Compute the coefficient of correlation
U
I 1 6 5 3 10 2 4 9 7 8
VT
II 6 4 9 8 1 2 3 10 5 7
6 ∑ 𝑑2
Soln : We have ρ =1-
𝑛 (𝑛2− 1)
∑ 𝑑2 = (1 − 6)2 + (6 − 4)2+(5 − 9)2 + (3 − 8)2 +(10 − 1)2 +(2 − 2)2 +(4 − 3)2 + (9 − 10)2
= 25 + 4+ 16 + 25 + 81 + 0 +1 +1 + 4 + 1 =158
6 (158)
Hence 𝜌 = 1 – = 0.042Ten students got the following percentage of marks
10(102 − 1)
in two subjects x and y. Compute their rank correlation coefficient.
Marks in x 78 36 98 25 75 82 90 62 65 39
Marks in y 84 51 91 60 68 62 86 58 53 47
Soln : We prepare the table consisting of the given data along with the ranks assigned
according to their order of the magnitude. In the subject x, 98 will be awarded
rank 1, 90 as rank 2 and so on.
6 ∑ 𝑑2
We have ρ =1- and n = 10 for the given data.
U
𝑛 (𝑛2− 1)
VT
6 (30)
=1- 10(102− 1)
= 0.82
2. Ten competitors in music contest are ranked by 3 judges A, B,C in the following order.
Use the rank correlation coefficient to decide which pair of judges have the nearest
A 1 6 5 10 3 2 4 9 7 8
B 3 5 8 4 7 10 2 1 6 9
C 6 4 9 8 1 2 3 10 5 7
Soln : We shall compute 𝜌𝐴𝐵 , 𝜌𝐵𝐶 , 𝜌𝐶𝐴 with the help of the following table where d is
the difference in ranks.
A B C 2
𝑑𝐴𝐵 𝑑2𝐵𝐶 2
𝑑𝐶𝐴
1 3 6 4 9 25
6 5 4 1 1 4
5 8 9 9 1 16
10 4 8 36 16 4
3 7 1 16 36 4
2 10 2 64 64 0
4 2 3 4 1 1
9 1 10 64 81 1
7 6 5 1 1 4
8 9 7 1 4 1
∑ 𝑑2 ∑ 𝑑2 ∑ 𝑑2
𝐴𝐵 𝐵𝐶 𝐶𝐴
= 200 = 214 = 60
∑ 𝑑2
We have ρ = 1 - 6
and n = 10 for the given data.
𝑛 (𝑛2− 1)
6 (200)
A 6 (214)
D
Now, 𝜌𝐴𝐵 = 1 - 10(102− 1) = - 0.21 , 𝜌𝐵𝐶 = 1-
10(102− 1)
= - 0.297
AD
6 (60)
𝜌𝐶𝐴 = 1-
10(102− 1)
= + 0.636
It may be observed that 𝜌𝐴𝐵 and 𝜌𝐵𝐶 are negative which means their tastes
(A &B; B &C) are opposite. But 𝜌𝐶𝐴 is positive and is nearer to 1.(perfect correlation)
U
VT
CURVE FITTING
CONTENTS:
❖ Curve fitting by the method of least squares
❖ Fitting of curves of the form
y = ax+ b
y = ax2+ bx + c
y = aebx
CURVE FITTING
We have straight line that sounds as best approximate to the actual curve y=f(x)
passing through ‘n’ points (𝑥𝑖, 𝑦𝑖 ) , i=0,1.2 ............. n equation of a straight
line is
y = a + bx (1)
A
D
Then for ‘n’ points (2) i i Y =(a+𝑏𝑥𝑖) .......... (2)
AD
Let us take equation of parabola called parabola of best fit in the form
y= a𝑥2 + bx + c
normal equations are
∑ 𝑦 = 𝑎 ∑ 𝑥2 + 𝑏 ∑ 𝑥 + 𝑛𝑐
∑ 𝑥𝑦 = 𝑎 ∑ 𝑥3 + 𝑏 ∑ 𝑥2 + 𝑐 ∑ 𝑥
∑ 𝑥2𝑦 = 𝑎 ∑ 𝑥4 + 𝑏 ∑ 𝑥3 + 𝑐 ∑ 𝑥2
Fit a curve of the form y=a𝒃𝒙:
∑ 𝑌 = 𝑛𝐴 + 𝐵 ∑ 𝑥 …..(3)
∑ 𝑥𝑌 = 𝐴 ∑ 𝑥 + 𝐵 ∑ 𝑥2 …..(4)
Solving the normal equation (3) & (4) for a & b . Substitute these values in (1) we get
curve of best fit of the form y= 𝑎𝑏𝑥
A
D
PROBLEMS:
AD
x: 5 10 15 20 25
U
y: 16 19 23 30 26
VT
∑ 𝑥𝑦 = 𝑎 ∑ 𝑥 + 𝑏 ∑ 𝑥2 …..(3)
x y 𝑥2 xy
5 16 25 80
10 19 100 190
15 23 225 345
20 26 400 520
25 30 625 750
∑ 𝑥 = 75 ∑ 𝑦 = 114 ∑ 𝑥2 = 1375 ∑ 𝑥𝑦 = 1885
x: 1 2 3 4 5
y: 14 13 9 5 2
Soln : Let y =a + b x ……(1)
x y 𝑥2 xy
1 14 1 14
2 13
A 4 26
3 9
D 9 27
4 5 16 20
AD
5 2 25 10
∑ 𝑥 = 15 ∑ 𝑦 = 43 ∑ 𝑥2 = 55 ∑ 𝑥𝑦 = 97
U
VT
∑ 𝑥𝑦 = 𝑎 ∑ 𝑥 + 𝑏 ∑ 𝑥2 …..(3 )
43 15a +15b , 97=15a +56b , a = 18.2 ,,b = -3.2 equn(1)Becomes y = 18.2 -3.2 x
x: 0 1 2 3 4
y: 1 1.8 3.3 4.5 6.3
Soln : Let y =a + b x ……(1)
∑ 𝑥𝑦 = 𝑎 ∑ 𝑥 + 𝑏 ∑ 𝑥2 …..(3)
X y 𝑥2 xy
0 1 0 0
1 1.8 1 1.8
2 3.3 4 6.6
3 4.5 9 13.5
4 6.3 16 25.2
∑ 𝑥 = 10 ∑ 𝑦 = 16.9
A
∑ 𝑥2 = 30 ∑ 𝑥𝑦 = 47.1
D
AD
b = 1.33
equ(1)Becomes y = 0.72 + 1.33 x
VT
4. If p is the pull required to lift a load by means of pulley block. Find a linear
block of the form p=MW+C Connected p &w using following data
w: 50 70 100 120
p: 12 15 21 25 Compute p when W=150.
∑ 𝑥𝑦 = 𝑎 ∑ 𝑥 + 𝑏 ∑ 𝑥2 …..(3)
x y 𝑥2 xy
50 12 2,500 600
70 15 4,900 1,050
100 21 10,000 2,100
∑ 𝑥𝑦 = 𝑎 ∑ 𝑥 + 𝑏 ∑ 𝑥2 + 𝑐 ∑ 𝑥3 (3)
VT
∑ 𝑥2𝑦 = 𝑎 ∑ 𝑥2 + 𝑏 ∑ 𝑥3 + 𝑐 ∑ 𝑥4 (4)
x y 𝑥2 𝑥3 𝑥4 xy
𝑥2𝑦
1 1.7 1 1 1 1.7 1.7
X y Y=logy
A 𝑥2 xY
D
0 8.12 2.093 0 0
2 10 2.302 4 4.604
AD
x: 1 2 3 4 5
y: 10 12 13 16 19
2 12 4 8 16 24 14
3 13 9 27 81 39 117
`4 16 16 64 256 64 256
6. The revolution 𝒓 and the time 𝒕 are related by 𝒓 = 𝒂𝒕𝟐 + 𝒃𝒕 + 𝒄 , Estimate the number of
U
Revolution 5 10 15 20 25 30 35
time 1.2 1.6 1.9 2.1 2.4 2.6 3
𝑥 1 5 7 9 12
𝑦 10 15 12 15 21
A
34 𝐴 + 300𝑏 = 94.1439.
D
⟹ 𝐴 = 2.2487, 𝑏 = 0.0590. .
And 𝑎 = 𝑒 𝐴 = 9.4754. ∴ 𝑦 = 9.4754𝑒0.0590𝑥 .
AD
x: 1 1.5 2 2.5
U
x y X=logx Y=logy 𝑋2 XY
1 2.5 0 0.916 0 0
1.5 5.62 0.405 1.726 0.164 0.699
2 10.0 0.693 2.302 0.480 1.595
2.5 15.6 0.916 2.747 0.839 2.516