In [65]:

```
import numpy
A = numpy.zeros([3,8])
print "The first row of A denotes the no. of students falling in the marks group starting from (5 −10)... till (40−45)"
A[0] = [5,6,15,10,5,4,2,2]
print "the second row denotes cumulative frequency (less than)"
A[1,0] = 5
for i in range(1,8):
A[1,i] = A[1,i-1]+A[0,i]
print "the third row denotes cumulative frequency(more than)"
A[2,0] = 49
for i in range (1,8):
A[2,i] = A[2,i-1]-A[0,i-1]
print A
```

In [63]:

```
import numpy
A = numpy.zeros([5,16])
print "The first row of A represents the mid values of weekly earnings having interval of 2 in each class=x "
A[0] = [11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41]
print "The second row denotes the no. of employees or in other words frequency=f "
A[1]=[3,6,10,15,24,42,75,90,79,55,36,26,19,13,9,7]
print "Third row denotes f∗x"
for i in range(0,16):
A[2,i] = A[0,i]*A[1,i]
print "Fourth row denotes u=(x−25)/2 "
for i in range(0,16):
A[3,i] = (A[0,i]-25)/2
print "Fifth row denotes f∗x"
for i in range(0,16):
A[4,i] = A[3,i]*A[1,i]
print A
b = 0
print "Sum of all elements of third row=",
for i in range(0,16):
b = b+A[2,i]
print b
f = 0
print "Sum of all elements of second row=",
for i in range(0,16):
f = f+A[1,i]
print f
print "mean=",b/f
d = 0
print "Sum of all elements of fifth row= ",
for i in range(0,16):
d = d+A[4,i]
print d
print "mean by step deviation method= ",25+(2*d/f)
```

In [47]:

```
import numpy
A = numpy.zeros([3,8])
print "The first row of A denotes the no. of students falling in the marks group startin from (5−10)... till (40−45)"
A[0] = [5,6,15,10,5,4,2,2]
print "The second row denotes cumulative frequency (less than)"
A[1]=[5,11,26,36,41,45,47,49]
print "The third row denotes cumulative frequency (more than)"
A[2] = [49,44,38,23,13,8,4,2]
print A
print "Median falls in the class (15−20)=l+((n/2−c)∗h)/f= ",15+((49/2-11)*5)/15
print "Lower quartile also falls in the class (15−20)="
Q1 = 15+((49/4-11)*5)/15
print "Upper quartile also falls in the class (25−30)="
Q3 =25+((3*49/4-36)*5)/5
print "Semiinter quartile range= ",(Q3-Q1)/2
```

In [66]:

```
import numpy
A = numpy.zeros([3,10])
print "The first row of A denotes the roll no. of students form 1 to 10 and that of B denotes form 11 to 20 "
A[0] = [1,2,3,4,5,6,7,8,9,10]
B[0] = [11,12,13,14,15,16,17,18,19,20]
print "The second row of A and B denotes the corresponding marks in physics"
A[1] = [53,54,52,32,30,60,47,46,35,28]
B[1] = [25,42,33,48,72,51,45,33,65,29]
print "The third row denotes the corresponding marks in chemistry"
A[2] = [58,55,25,32,26,85,44,80,33,72]
B[2] = [10,42,15,46,50,64,39,38,30,36]
print "Median marks in physics=arithmetic mean of 10th and 11th student = ",(28+25)/2
print "Median marks in chemistry=arithmetic mean of 10th and 11th student = ",(72+10)/2
```

In [9]:

```
print "Let the misssing frequencies be f1 and f2 "
print "Sum of given frequencies=12+30+65+25+18 = ",
c =12+30+65+25+18
print c
print "So, f1+f2=229−c = ",229-c
print "Median=46=40+(114.5−(12+30+f1))∗10/65)"
print "f1=33.5=34 "
f1 = 34
f2 = 45
```

In [10]:

```
import sympy
s = sympy.Symbol('s')
print "Let the eqidistance be s, then"
t1 = s/30
t2 = s/40
t3 = s/50
print "Average speed = total distance/total time taken",3*s/(t1+t2+t3)
```

In [68]:

```
import numpy
A = numpy.zeros([5,7])
print "The first row denotes the size of item "
A[0,:] = [6,7,8,9,10,11,12]
print "The second row denotes the corresponding frequency(f)"
A[1,:] = [3,6,9,13,8,5,4]
print "The third row denotes the corresponding deviation(d)"
A[2,:] = [-3,-2,-1,0,1,2,3]
print "The fourth row denotes the corresponding f∗d "
for i in range(0,7):
A[3,i] = A[1,i]*A[2,i]
print "The fifth row denotes the corresponding f∗dˆ2 "
for i in range(0,7):
A[4,i] = A[1,i]*(A[2,i]**2)
print A
b = 0
print "Sum of fourth row elements= ",
for i in range(0,7):
b = b+A[3,i]
print b
c = 0
print "Sum of fifth row elements= ",
for i in range(0,7):
c = c+A[4,i]
print c
d = 0
print "Sum of all frequencies = ",
for i in range(0,7):
d = d+A[1,i]
print d
print "mean=9+b/d = ",9+b/d
print "Standard deviation = (c/d)ˆ0.5 = ",(c/d)**0.5
```

In [70]:

```
import numpy
A = numpy.zeros([6,9])
print "The first row of A represents the mid values of wage classes having interval of 8 in each class=x "
A[0] = [8.5,16.5,24.5,32.5,40.5,48.5,56.5,64.5,72.5]
print "The second row denotes the no. of men or in other words frequency=f "
A[1] = [2,24,21,18,5,3,5,8,2]
print "Third row denotes f∗x "
for i in range(0,9):
A[2,i] = A[0,i]*A[1,i]
print "Fourth row denotes d=(x−32.5)/8 "
for i in range(0,9):
A[3,i] = (A[0,i]-32.5)/8
print "Fifth row denotes f∗d "
for i in range(0,9):
A[4,i] = A[3,i]*A[1,i]
print "Sixth row denotes f∗(dˆ2)"
for i in range(0,9):
A[5,i] = A[3,i]**2*A[1,i]
print A
b = 0
print "Sum of all elements of sixth row= ",
for i in range(0,9):
b = b+A[5,i]
print b
f = 0
print "Sum of all elements of second row= ",
for i in range(0,9):
f = f+A[1,i]
print f
print "mean= ",b/f
d = 0
print "Sum of all elements of fifth row= ",
for i in range(0,9):
d = d+A[4,i]
print "Mean wage= ",32.5+(8*d/f)
print "standard deviation= ",8*(b/f-(d/f)**2)
```

In [72]:

```
import numpy
A = numpy.zeros([3,10])
B = numpy.zeros([3,10])
print "The first row of A denotes the scores of A and that of B denotes that of B "
A[0] = [12,115,6,73,7,19,119,36,84,29]
B[0] = [47,12,16,42,4,51,37,48,13,0]
print "The second row of A and B denotes the corresponding deviation "
for i in range (0,10):
A[1,i] = A[0,i]-51
B[1,i] = B[0,i]-51
print "The third row of A and B denotes the corresponding deviation square "
for i in range (0,10):
A[2,i] = A[1,i]**2
B[2,i] = B[1,i]**2
print A
print B
b = 0
print "Sum of second row elements of A=b=",
for i in range (0,10):
b = b+A[1,i]
print b
c = 0
print "sum of second row elements of B=c=",
for i in range (0,10):
c = c+B[1,i]
print c
d = 0
print "Sum of third row elements of A=d=",
for i in range (0,10):
d = d+A[2,i]
print d
e = 0
print "Sum of second row elements of B=e=",
for i in range (0,10):
e = e+B[2,i]
print e
print "Arithmetic mean of A= ",
f = 51+b/10
print f
print "Standard deviation of A= ",
g = (d/10-(b/10)**2)**0.5
print g
print "Arithmetic mean of B= ",
h = 51+c/10
print h
print "Standard deviation of A= ",
i = (e/10-(c/10)**2)**0.5
print i
print "Coefficient of variation of A=",(g/f)*100
print "Coefficient of variation of B=",(i/h)*100
```

In [14]:

```
print "If m is the mean of entire data, then"
m = (50*113+60*120+90*115)/(50+60+90)
print m
print "If s is the standard deviation of entire data, then "
s = (((50*6**2)+(60*7**2)+(90*8**2)+(50*3**2)+(60*4**2)+(90*1**2))/200)**0.5
print s
```

In [73]:

```
import numpy
A = numpy.zeros([2,8])
print "The first row of A denotes the no. of persons falling in the weight group starting from (70−80)... till (140−150)"
A[0] = [12,18,35,42,50,45,20,8]
print "The second row denotes cumulative frequency"
A[1,0] = 12
for i in range(1,8):
A[1,i] = A[1,i-1]+A[0,i]
print "Median falls in the class (110−120) = l+((n/2−c)∗h)/f= ",
Q2 = 110+(8*10)/50
print Q2
print "Lower quartile also falls in the class (90−100)= ",
Q1 = 90+(57.5-30)*10/35
print Q1
print "Upper quartile also falls in the class (120−130)= ",
Q3 = 120+(172.5-157)*10/45
print Q3
print "Quartile coefficient of skewness= ",(Q1+Q3-2*Q2)/(Q3-Q1)
```

In [76]:

```
import numpy
A = numpy.zeros([7,10])
print "The first row of A denotes the corresponding I.R. of students "
A[0] = [105,104,102,101,100,99,98,96,93,92]
print "The second row denotes the corresponding deviation of I.R."
for i in range(0,10):
A[1,i] = A[0,i]-99
print "The third row denotes the square of corresponding deviation of I.R."
for i in range(0,10):
A[2,i] = A[1,i]**2
print "The fourth row denotes the corresponding E.R. of students "
A[3] = [101,103,100,98,95,96,104,92,97,94]
print "The fifth row denotes the corresponding deviation of E.R."
for i in range(0,10):
A[4,i] = A[3,i]-98
print "The sixth row denotes the square of corresponding deviation of E.R."
for i in range(0,10):
A[5,i] = A[4,i]**2
print "The seventh row denotes the product of the two corresponding deviations"
for i in range(0,10):
A[6,i] = A[1,i]*A[4,i]
print A
a = 0
print "The sum of elements of first row=a = ",
for i in range(0,10):
a = a+A[0,i]
print a
b = 0
print "The sum of elements of second row=b = ",
for i in range(0,10):
b = b+A[1,i]
print b
c = 0
print "The sum of elements of third row=c = ",
for i in range(0,10):
c = c+A[2,i]
print c
d = 0
print "The sum of elements of fourth row=d = ",
for i in range(0,10):
d = d+A[3,i]
print d
e = 0
print "The sum of elements of fifth row=e = ",
for i in range(0,10):
e = e+A[4,i]
print e
f = 0
print "The sum of elements of sixth row=d = ",
for i in range(0,10):
f = f+A[5,i]
print f
g = 0
print "The sum of elements of seventh row=d = ",
for i in range(0,10):
g = g+A[6,i]
print g
print "Coefficient of correlation = ",g/(c*f)**0.5
```