0% found this document useful (0 votes)
21 views12 pages

Module - 1 Lab Experiment Questions, Solutions and Programs

The document contains a series of lab experiment questions and Python programs focused on calculating the mean and correlation coefficient for given datasets of x and y values. Each experiment includes a detailed solution, Python code, and expected output for clarity. The experiments demonstrate the application of statistical concepts using Python programming.

Uploaded by

danthuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Module - 1 Lab Experiment Questions, Solutions and Programs

The document contains a series of lab experiment questions and Python programs focused on calculating the mean and correlation coefficient for given datasets of x and y values. Each experiment includes a detailed solution, Python code, and expected output for clarity. The experiments demonstrate the application of statistical concepts using Python programming.

Uploaded by

danthuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

24MAT21 Lab Experiment Questions and Python Programs

Experiment 01: - Mean of 𝒙 and 𝒚

1. Write a python program to evaluate the mean of 𝒙 and 𝒚 from the following data
𝑥 105 104 102 101 100 99 98 96 93 92
𝑦 101 103 100 98 95 96 104 92 97 94

Solution: -
We know that
Mean of 𝑥 values is

𝑥̅ = ∑(𝑥) = [990] = 99

∴ 𝑥̅ = 99

Mean of 𝑦 values is

𝑦 = ∑(𝑦) = [980] = 98

∴ 𝑦 = 98
Program: -
x = [105, 104, 102, 101, 100, 99, 98, 96, 93, 92]
y = [101, 103, 100, 98, 95, 96, 104, 92, 97, 94]
Mx = sum(x)/len(x)
My = sum(y)/len(y)
print("Mean(x) = ", Mx)
print("Mean(y) = ", My)

Output: -
2. Write a python program to evaluate the mean of 𝒙 and 𝒚 from the following data
𝑥 78 89 97 69 59 79 68 57
𝑦 125 137 156 112 107 138 123 108

Solution: -
We know that
Mean of 𝑥 values is

𝑥̅ = ∑(𝑥) = [596] = 74.5

∴ 𝑥̅ = 74.5

Mean of 𝑦 values is

𝑦 = ∑(𝑦) = [1006] = 125.75

∴ 𝑦 = 125.75
Program: -
import numpy as np
x = [78, 89, 97, 69, 59, 79, 68, 57]
y = [125, 137, 156, 112, 107, 138, 123, 108]
Mx = [Link](x)
My =[Link](y)
print("Mean(x) = ", Mx)
print("Mean(y) = ", My)

Output: -
3. Write a python program to evaluate the mean of 𝒙 and 𝒚 from the following data
𝑥 55 56 58 59 60 60 62
𝑦 35 38 38 39 44 43 45

Solution: -
We know that
Mean of 𝑥 values is

𝑥̅ = ∑(𝑥) = [410] = 58.57

∴ 𝑥̅ = 58.57

Mean of 𝑦 values is

𝑦 = ∑(𝑦) = [282] = 40.29

∴ 𝑦 = 40.29
Program: -
import statistics as st
x = [55, 56, 58, 59, 60, 60, 62]
y = [35, 38, 38, 39, 44, 43, 45]
Mx = [Link](x)
My = [Link](y)
print("Mean(x) = ", round(Mx, 2))
print("Mean(y) = ", round(My, 2))

Output: -
Experiment 02: - Correlation coefficient between 𝒙 and 𝒚

1. Write a python program to evaluate the correlation coefficient of 𝒙 and 𝒚 to the data
𝑥 105 104 102 101 100 99 98 96 93 92
𝑦 101 103 100 98 95 96 104 92 97 94

Solution: -
We know that
∑( . )
Correlation coefficient is 𝑟 =
∑( ).∑( )
Here 𝑋 = 𝑥 − 𝑥̅ , 𝑌 = 𝑦 − 𝑦

Where 𝑥̅ = ∑(𝑥) = (990) = 99 and 𝑦 = ∑(𝑦) = (980) = 98

𝑿 = 𝒙 − 𝟗𝟗 𝒀 = 𝒚 − 𝟗𝟖 𝑿. 𝒀 𝑿𝟐 𝒀𝟐
6 3 18 36 9
5 5 25 25 25
3 2 6 9 4
2 0 0 4 0
1 -3 -3 1 9
0 -2 0 0 4
-1 6 -6 1 36
-3 -6 18 9 36
-6 -1 6 36 1
-7 -4 28 49 16
Sum 92 170 140

Now 𝑟 = = 0.596
( ).( )
Program: -
import numpy as np
x = [105, 104, 102, 101, 100, 99, 98, 96, 93, 92]
y = [101, 103, 100, 98, 95, 96, 104, 92, 97, 94]
Mx = [Link](x)
My = [Link](y)
print("Mean(x) = ", Mx)
print("Mean(y) = ", My)
r = [Link](x,y)
print("Correlation coefficient is r =", round(r[0,1],3))

Output: -
2. Write a python program to evaluate the correlation coefficient of 𝒙 and 𝒚 to the data
𝑥 78 89 97 69 59 79 68 57
𝑦 125 137 156 112 107 138 123 108

Solution: -
We know that
∑( . )
Correlation coefficient is 𝑟 =
∑( ).∑( )
Here 𝑋 = 𝑥 − 𝑥̅ , 𝑌 = 𝑦 − 𝑦

Where 𝑥̅ = ∑(𝑥) = (596) = 74.5 and 𝑦 = ∑(𝑦) = (1006) = 125.75

𝑿 = 𝒙 − 𝟕𝟒. 𝟓 𝒀 = 𝒚 − 𝟏𝟐𝟓. 𝟕𝟓 𝑿. 𝒀 𝑿𝟐 𝒀𝟐
3.5 -0.75 -2.625 12.25 0.5625
14.5 11.25 163.125 210.25 126.5625
22.5 30.25 680.625 506.25 915.0625
-5.5 -13.75 75.625 30.25 189.0625
-15.5 -18.75 290.625 240.25 351.5625
4.5 12.25 55.125 20.25 150.0625
-6.5 -2.75 17.875 42.25 7.5625
-17.5 -17.75 310.625 306.25 315.0625
Sum 1591.0 1368.0 2055.5

Now 𝑟 = = 0.949
( ).( . )
Program: -
import numpy as np
x = [78, 89, 97, 69, 59, 79, 68, 57]
y = [125, 137, 156, 112, 107, 138, 123, 108]
Mx = [Link](x)
My = [Link](y)
print("Mean(x) = ", Mx)
print("Mean(y) = ", My)
r = [Link](x,y)
print("Correlation coefficient is r =", round(r[0,1],3))

Output: -
3. Write a python program to evaluate the correlation coefficient of 𝒙 and 𝒚 to the data
𝑥 25 38 35 32 31 36 29 38 34 32
𝑦 43 46 49 41 36 32 31 30 33 39

Solution: -
We know that
∑( . )
Correlation coefficient is 𝑟 =
∑( ).∑( )
Here 𝑋 = 𝑥 − 𝑥̅ , 𝑌 = 𝑦 − 𝑦

Where 𝑥̅ = ∑(𝑥) = (330) = 33 and 𝑦 = ∑(𝑦) = (380) = 38

𝑿 = 𝒙 − 𝟑𝟑 𝒀 = 𝒚 − 𝟑𝟖 𝑿. 𝒀 𝑿𝟐 𝒀𝟐
-8 5 -40 64 25
5 8 40 25 64
2 11 22 4 121
-1 3 -3 1 9
-2 -2 4 4 4
3 -6 -18 9 36
-4 -7 28 16 49
5 -8 -40 25 64
1 -5 -5 1 25
-1 1 -1 1 1
Sum -13 150 398

Now 𝑟 = = −0.053
( ).( )
Program: -
import numpy as np
x = [25, 38, 35, 32, 31, 36, 29, 38, 34, 32]
y = [43, 46, 49, 41, 36, 32, 31, 30, 33, 39]
Mx = [Link](x)
My = [Link](y)
print("Mean(x) = ", Mx)
print("Mean(y) = ", My)
r = [Link](x,y)
print("Correlation coefficient(x, y) = ", round(r[0,1],3))

Output: -

You might also like