summaryrefslogtreecommitdiff
path: root/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb
diff options
context:
space:
mode:
authorTrupti Kini2016-05-03 23:30:25 +0600
committerTrupti Kini2016-05-03 23:30:25 +0600
commit6142c8add48d9e8b4445d0693739e1fddb39d09f (patch)
tree3a239c80048fa82b06eb555796d60d9adfc27b79 /Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb
parent09174527d359bd85404d15d76fabd891c7e5ad6b (diff)
downloadPython-Textbook-Companions-6142c8add48d9e8b4445d0693739e1fddb39d09f.tar.gz
Python-Textbook-Companions-6142c8add48d9e8b4445d0693739e1fddb39d09f.tar.bz2
Python-Textbook-Companions-6142c8add48d9e8b4445d0693739e1fddb39d09f.zip
Added(A)/Deleted(D) following books
A Engineering_Thermodynamics_by_Dr._S._S._Khandare/README.txt A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter1.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter10.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter13.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter2.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter21.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter22.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter24.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter26.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter27.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter28.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter34.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter35.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter5.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter6.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter9.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/screenshots/screen1.png A Higher_Engineering_Mathematics_by_B._S._Grewal/screenshots/screen2.png A Higher_Engineering_Mathematics_by_B._S._Grewal/screenshots/screen3.png A sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical_fiber.ipynb
Diffstat (limited to 'Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb')
-rw-r--r--Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb762
1 files changed, 762 insertions, 0 deletions
diff --git a/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb b/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb
new file mode 100644
index 00000000..a7ba913c
--- /dev/null
+++ b/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb
@@ -0,0 +1,762 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 23 : Statistical Methods"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.1, page no. 618"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A denotes the no. of students falling in the marks group starting from (5 −10)... till (40−45)\n",
+ "the second row denotes cumulative frequency (less than)\n",
+ "the third row denotes cumulative frequency(more than)\n",
+ "[[ 5. 6. 15. 10. 5. 4. 2. 2.]\n",
+ " [ 5. 11. 26. 36. 41. 45. 47. 49.]\n",
+ " [ 49. 44. 38. 23. 13. 8. 4. 2.]]\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([3,8])\n",
+ "print \"The first row of A denotes the no. of students falling in the marks group starting from (5 −10)... till (40−45)\"\n",
+ "A[0] = [5,6,15,10,5,4,2,2]\n",
+ "print \"the second row denotes cumulative frequency (less than)\"\n",
+ "A[1,0] = 5\n",
+ "for i in range(1,8):\n",
+ " A[1,i] = A[1,i-1]+A[0,i]\n",
+ "print \"the third row denotes cumulative frequency(more than)\"\n",
+ "A[2,0] = 49\n",
+ "for i in range (1,8):\n",
+ " A[2,i] = A[2,i-1]-A[0,i-1]\n",
+ "print A"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.2, page no. 619"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A represents the mid values of weekly earnings having interval of 2 in each class=x \n",
+ "The second row denotes the no. of employees or in other words frequency=f \n",
+ "Third row denotes f∗x\n",
+ "Fourth row denotes u=(x−25)/2 \n",
+ "Fifth row denotes f∗x\n",
+ "[[ 1.10000000e+01 1.30000000e+01 1.50000000e+01 1.70000000e+01\n",
+ " 1.90000000e+01 2.10000000e+01 2.30000000e+01 2.50000000e+01\n",
+ " 2.70000000e+01 2.90000000e+01 3.10000000e+01 3.30000000e+01\n",
+ " 3.50000000e+01 3.70000000e+01 3.90000000e+01 4.10000000e+01]\n",
+ " [ 3.00000000e+00 6.00000000e+00 1.00000000e+01 1.50000000e+01\n",
+ " 2.40000000e+01 4.20000000e+01 7.50000000e+01 9.00000000e+01\n",
+ " 7.90000000e+01 5.50000000e+01 3.60000000e+01 2.60000000e+01\n",
+ " 1.90000000e+01 1.30000000e+01 9.00000000e+00 7.00000000e+00]\n",
+ " [ 3.30000000e+01 7.80000000e+01 1.50000000e+02 2.55000000e+02\n",
+ " 4.56000000e+02 8.82000000e+02 1.72500000e+03 2.25000000e+03\n",
+ " 2.13300000e+03 1.59500000e+03 1.11600000e+03 8.58000000e+02\n",
+ " 6.65000000e+02 4.81000000e+02 3.51000000e+02 2.87000000e+02]\n",
+ " [ -7.00000000e+00 -6.00000000e+00 -5.00000000e+00 -4.00000000e+00\n",
+ " -3.00000000e+00 -2.00000000e+00 -1.00000000e+00 0.00000000e+00\n",
+ " 1.00000000e+00 2.00000000e+00 3.00000000e+00 4.00000000e+00\n",
+ " 5.00000000e+00 6.00000000e+00 7.00000000e+00 8.00000000e+00]\n",
+ " [ -2.10000000e+01 -3.60000000e+01 -5.00000000e+01 -6.00000000e+01\n",
+ " -7.20000000e+01 -8.40000000e+01 -7.50000000e+01 0.00000000e+00\n",
+ " 7.90000000e+01 1.10000000e+02 1.08000000e+02 1.04000000e+02\n",
+ " 9.50000000e+01 7.80000000e+01 6.30000000e+01 5.60000000e+01]]\n",
+ "Sum of all elements of third row= 13315.0\n",
+ "Sum of all elements of second row= 509.0\n",
+ "mean= 26.1591355599\n",
+ "Sum of all elements of fifth row= 295.0\n",
+ "mean by step deviation method= 26.1591355599\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([5,16])\n",
+ "print \"The first row of A represents the mid values of weekly earnings having interval of 2 in each class=x \"\n",
+ "A[0] = [11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41]\n",
+ "print \"The second row denotes the no. of employees or in other words frequency=f \"\n",
+ "A[1]=[3,6,10,15,24,42,75,90,79,55,36,26,19,13,9,7]\n",
+ "print \"Third row denotes f∗x\"\n",
+ "for i in range(0,16):\n",
+ " A[2,i] = A[0,i]*A[1,i]\n",
+ "print \"Fourth row denotes u=(x−25)/2 \"\n",
+ "for i in range(0,16):\n",
+ " A[3,i] = (A[0,i]-25)/2\n",
+ "print \"Fifth row denotes f∗x\"\n",
+ "for i in range(0,16):\n",
+ " A[4,i] = A[3,i]*A[1,i]\n",
+ "print A\n",
+ "b = 0\n",
+ "print \"Sum of all elements of third row=\",\n",
+ "for i in range(0,16):\n",
+ " b = b+A[2,i]\n",
+ "print b\n",
+ "f = 0\n",
+ "print \"Sum of all elements of second row=\",\n",
+ "for i in range(0,16):\n",
+ " f = f+A[1,i]\n",
+ "print f\n",
+ "print \"mean=\",b/f\n",
+ "d = 0\n",
+ "print \"Sum of all elements of fifth row= \",\n",
+ "for i in range(0,16):\n",
+ " d = d+A[4,i]\n",
+ "print d\n",
+ "print \"mean by step deviation method= \",25+(2*d/f)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.3, page no. 620"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A denotes the no. of students falling in the marks group startin from (5−10)... till (40−45)\n",
+ "The second row denotes cumulative frequency (less than)\n",
+ "The third row denotes cumulative frequency (more than)\n",
+ "[[ 5. 6. 15. 10. 5. 4. 2. 2.]\n",
+ " [ 5. 11. 26. 36. 41. 45. 47. 49.]\n",
+ " [ 49. 44. 38. 23. 13. 8. 4. 2.]]\n",
+ "Median falls in the class (15−20)=l+((n/2−c)∗h)/f= 19\n",
+ "Lower quartile also falls in the class (15−20)=\n",
+ "Upper quartile also falls in the class (25−30)=\n",
+ "Semiinter quartile range= 5\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([3,8])\n",
+ "print \"The first row of A denotes the no. of students falling in the marks group startin from (5−10)... till (40−45)\"\n",
+ "\n",
+ "A[0] = [5,6,15,10,5,4,2,2]\n",
+ "print \"The second row denotes cumulative frequency (less than)\"\n",
+ "A[1]=[5,11,26,36,41,45,47,49]\n",
+ "print \"The third row denotes cumulative frequency (more than)\"\n",
+ "A[2] = [49,44,38,23,13,8,4,2]\n",
+ "print A\n",
+ "print \"Median falls in the class (15−20)=l+((n/2−c)∗h)/f= \",15+((49/2-11)*5)/15\n",
+ "print \"Lower quartile also falls in the class (15−20)=\"\n",
+ "Q1 = 15+((49/4-11)*5)/15\n",
+ "print \"Upper quartile also falls in the class (25−30)=\"\n",
+ "Q3 =25+((3*49/4-36)*5)/5\n",
+ "print \"Semiinter quartile range= \",(Q3-Q1)/2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.4, page no. 620"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 66,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A denotes the roll no. of students form 1 to 10 and that of B denotes form 11 to 20 \n",
+ "The second row of A and B denotes the corresponding marks in physics\n",
+ "The third row denotes the corresponding marks in chemistry\n",
+ "Median marks in physics=arithmetic mean of 10th and 11th student = 26\n",
+ "Median marks in chemistry=arithmetic mean of 10th and 11th student = 41\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([3,10])\n",
+ "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 \"\n",
+ "A[0] = [1,2,3,4,5,6,7,8,9,10]\n",
+ "B[0] = [11,12,13,14,15,16,17,18,19,20]\n",
+ "print \"The second row of A and B denotes the corresponding marks in physics\"\n",
+ "A[1] = [53,54,52,32,30,60,47,46,35,28]\n",
+ "B[1] = [25,42,33,48,72,51,45,33,65,29]\n",
+ "print \"The third row denotes the corresponding marks in chemistry\"\n",
+ "A[2] = [58,55,25,32,26,85,44,80,33,72]\n",
+ "B[2] = [10,42,15,46,50,64,39,38,30,36]\n",
+ "print \"Median marks in physics=arithmetic mean of 10th and 11th student = \",(28+25)/2\n",
+ "print \"Median marks in chemistry=arithmetic mean of 10th and 11th student = \",(72+10)/2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.5, page no. 621"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Let the misssing frequencies be f1 and f2 \n",
+ "Sum of given frequencies=12+30+65+25+18 = 150\n",
+ "So, f1+f2=229−c = 79\n",
+ "Median=46=40+(114.5−(12+30+f1))∗10/65)\n",
+ "f1=33.5=34 \n"
+ ]
+ }
+ ],
+ "source": [
+ "print \"Let the misssing frequencies be f1 and f2 \"\n",
+ "print \"Sum of given frequencies=12+30+65+25+18 = \",\n",
+ "c =12+30+65+25+18\n",
+ "print c\n",
+ "print \"So, f1+f2=229−c = \",229-c\n",
+ "print \"Median=46=40+(114.5−(12+30+f1))∗10/65)\"\n",
+ "print \"f1=33.5=34 \"\n",
+ "f1 = 34\n",
+ "f2 = 45"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.6, page no. 622"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Let the eqidistance be s, then\n",
+ "Average speed = total distance/total time taken 1800/47\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "\n",
+ "s = sympy.Symbol('s')\n",
+ "print \"Let the eqidistance be s, then\"\n",
+ "t1 = s/30\n",
+ "t2 = s/40\n",
+ "t3 = s/50\n",
+ "print \"Average speed = total distance/total time taken\",3*s/(t1+t2+t3)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.7, page no. 623"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 68,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row denotes the size of item \n",
+ "The second row denotes the corresponding frequency(f)\n",
+ "The third row denotes the corresponding deviation(d)\n",
+ "The fourth row denotes the corresponding f∗d \n",
+ "The fifth row denotes the corresponding f∗dˆ2 \n",
+ "[[ 6. 7. 8. 9. 10. 11. 12.]\n",
+ " [ 3. 6. 9. 13. 8. 5. 4.]\n",
+ " [ -3. -2. -1. 0. 1. 2. 3.]\n",
+ " [ -9. -12. -9. 0. 8. 10. 12.]\n",
+ " [ 27. 24. 9. 0. 8. 20. 36.]]\n",
+ "Sum of fourth row elements= 0.0\n",
+ "Sum of fifth row elements= 124.0\n",
+ "Sum of all frequencies = 48.0\n",
+ "mean=9+b/d = 9.0\n",
+ "Standard deviation = (c/d)ˆ0.5 = 1.60727512683\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([5,7])\n",
+ "print \"The first row denotes the size of item \"\n",
+ "A[0,:] = [6,7,8,9,10,11,12]\n",
+ "print \"The second row denotes the corresponding frequency(f)\"\n",
+ "A[1,:] = [3,6,9,13,8,5,4]\n",
+ "print \"The third row denotes the corresponding deviation(d)\"\n",
+ "A[2,:] = [-3,-2,-1,0,1,2,3]\n",
+ "print \"The fourth row denotes the corresponding f∗d \"\n",
+ "for i in range(0,7):\n",
+ " A[3,i] = A[1,i]*A[2,i] \n",
+ "print \"The fifth row denotes the corresponding f∗dˆ2 \"\n",
+ "for i in range(0,7):\n",
+ " A[4,i] = A[1,i]*(A[2,i]**2)\n",
+ "print A\n",
+ "b = 0\n",
+ "print \"Sum of fourth row elements= \",\n",
+ "for i in range(0,7):\n",
+ " b = b+A[3,i]\n",
+ "print b\n",
+ "c = 0\n",
+ "print \"Sum of fifth row elements= \",\n",
+ "for i in range(0,7):\n",
+ " c = c+A[4,i]\n",
+ "print c\n",
+ "d = 0\n",
+ "print \"Sum of all frequencies = \",\n",
+ "for i in range(0,7):\n",
+ " d = d+A[1,i]\n",
+ "print d\n",
+ "print \"mean=9+b/d = \",9+b/d\n",
+ "print \"Standard deviation = (c/d)ˆ0.5 = \",(c/d)**0.5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.8, page no. 624"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 70,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A represents the mid values of wage classes having interval of 8 in each class=x \n",
+ "The second row denotes the no. of men or in other words frequency=f \n",
+ "Third row denotes f∗x \n",
+ "Fourth row denotes d=(x−32.5)/8 \n",
+ "Fifth row denotes f∗d \n",
+ "Sixth row denotes f∗(dˆ2)\n",
+ "[[ 8.5 16.5 24.5 32.5 40.5 48.5 56.5 64.5 72.5]\n",
+ " [ 2. 24. 21. 18. 5. 3. 5. 8. 2. ]\n",
+ " [ 17. 396. 514.5 585. 202.5 145.5 282.5 516. 145. ]\n",
+ " [ -3. -2. -1. 0. 1. 2. 3. 4. 5. ]\n",
+ " [ -6. -48. -21. 0. 5. 6. 15. 32. 10. ]\n",
+ " [ 18. 96. 21. 0. 5. 12. 45. 128. 50. ]]\n",
+ "Sum of all elements of sixth row= 375.0\n",
+ "Sum of all elements of second row= 88.0\n",
+ "mean= 4.26136363636\n",
+ "Sum of all elements of fifth row= Mean wage= 31.8636363636\n",
+ "standard deviation= 34.0402892562\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([6,9])\n",
+ "print \"The first row of A represents the mid values of wage classes having interval of 8 in each class=x \"\n",
+ "A[0] = [8.5,16.5,24.5,32.5,40.5,48.5,56.5,64.5,72.5]\n",
+ "print \"The second row denotes the no. of men or in other words frequency=f \"\n",
+ "A[1] = [2,24,21,18,5,3,5,8,2]\n",
+ "print \"Third row denotes f∗x \"\n",
+ "for i in range(0,9):\n",
+ " A[2,i] = A[0,i]*A[1,i] \n",
+ "print \"Fourth row denotes d=(x−32.5)/8 \"\n",
+ "for i in range(0,9):\n",
+ " A[3,i] = (A[0,i]-32.5)/8\n",
+ "print \"Fifth row denotes f∗d \"\n",
+ "for i in range(0,9):\n",
+ " A[4,i] = A[3,i]*A[1,i]\n",
+ "print \"Sixth row denotes f∗(dˆ2)\"\n",
+ "for i in range(0,9):\n",
+ " A[5,i] = A[3,i]**2*A[1,i]\n",
+ "print A\n",
+ "b = 0\n",
+ "print \"Sum of all elements of sixth row= \",\n",
+ "for i in range(0,9):\n",
+ " b = b+A[5,i]\n",
+ "print b\n",
+ "f = 0\n",
+ "print \"Sum of all elements of second row= \",\n",
+ "for i in range(0,9):\n",
+ " f = f+A[1,i]\n",
+ "print f\n",
+ "print \"mean= \",b/f\n",
+ "d = 0\n",
+ "print \"Sum of all elements of fifth row= \",\n",
+ "for i in range(0,9):\n",
+ " d = d+A[4,i]\n",
+ "print \"Mean wage= \",32.5+(8*d/f)\n",
+ "print \"standard deviation= \",8*(b/f-(d/f)**2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.9, page no. 626"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 72,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A denotes the scores of A and that of B denotes that of B \n",
+ "The second row of A and B denotes the corresponding deviation \n",
+ "The third row of A and B denotes the corresponding deviation square \n",
+ "[[ 12. 115. 6. 73. 7. 19. 119. 36. 84. 29.]\n",
+ " [ -39. 64. -45. 22. -44. -32. 68. -15. 33. -22.]\n",
+ " [ 1521. 4096. 2025. 484. 1936. 1024. 4624. 225. 1089. 484.]]\n",
+ "[[ 47. 12. 16. 42. 4. 51. 37. 48. 13. 0.]\n",
+ " [ -4. -39. -35. -9. -47. 0. -14. -3. -38. -51.]\n",
+ " [ 16. 1521. 1225. 81. 2209. 0. 196. 9. 1444. 2601.]]\n",
+ "Sum of second row elements of A=b= -10.0\n",
+ "sum of second row elements of B=c= -240.0\n",
+ "Sum of third row elements of A=d= 17508.0\n",
+ "Sum of second row elements of B=e= 9302.0\n",
+ "Arithmetic mean of A= 50.0\n",
+ "Standard deviation of A= 41.8306108012\n",
+ "Arithmetic mean of B= 27.0\n",
+ "Standard deviation of A= 18.8202019118\n",
+ "Coefficient of variation of A= 83.6612216024\n",
+ "Coefficient of variation of B= 69.7044515251\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([3,10])\n",
+ "B = numpy.zeros([3,10])\n",
+ "print \"The first row of A denotes the scores of A and that of B denotes that of B \"\n",
+ "A[0] = [12,115,6,73,7,19,119,36,84,29]\n",
+ "B[0] = [47,12,16,42,4,51,37,48,13,0]\n",
+ "print \"The second row of A and B denotes the corresponding deviation \"\n",
+ "for i in range (0,10):\n",
+ " A[1,i] = A[0,i]-51\n",
+ " B[1,i] = B[0,i]-51\n",
+ "print \"The third row of A and B denotes the corresponding deviation square \"\n",
+ "for i in range (0,10):\n",
+ " A[2,i] = A[1,i]**2\n",
+ " B[2,i] = B[1,i]**2\n",
+ "print A\n",
+ "print B\n",
+ "b = 0\n",
+ "print \"Sum of second row elements of A=b=\",\n",
+ "for i in range (0,10):\n",
+ " b = b+A[1,i]\n",
+ "print b\n",
+ "c = 0\n",
+ "print \"sum of second row elements of B=c=\",\n",
+ "for i in range (0,10):\n",
+ " c = c+B[1,i]\n",
+ "print c\n",
+ "d = 0\n",
+ "print \"Sum of third row elements of A=d=\",\n",
+ "for i in range (0,10):\n",
+ " d = d+A[2,i]\n",
+ "print d\n",
+ "e = 0\n",
+ "print \"Sum of second row elements of B=e=\",\n",
+ "for i in range (0,10):\n",
+ " e = e+B[2,i]\n",
+ "print e\n",
+ "print \"Arithmetic mean of A= \",\n",
+ "f = 51+b/10\n",
+ "print f\n",
+ "print \"Standard deviation of A= \",\n",
+ "g = (d/10-(b/10)**2)**0.5\n",
+ "print g\n",
+ "print \"Arithmetic mean of B= \",\n",
+ "h = 51+c/10\n",
+ "print h\n",
+ "print \"Standard deviation of A= \",\n",
+ "i = (e/10-(c/10)**2)**0.5\n",
+ "print i\n",
+ "print \"Coefficient of variation of A=\",(g/f)*100\n",
+ "print \"Coefficient of variation of B=\",(i/h)*100"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.10, page no. 628"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "If m is the mean of entire data, then\n",
+ "116\n",
+ "If s is the standard deviation of entire data, then \n",
+ "7.74596669241\n"
+ ]
+ }
+ ],
+ "source": [
+ "print \"If m is the mean of entire data, then\"\n",
+ "m = (50*113+60*120+90*115)/(50+60+90)\n",
+ "print m\n",
+ "print \"If s is the standard deviation of entire data, then \"\n",
+ "s = (((50*6**2)+(60*7**2)+(90*8**2)+(50*3**2)+(60*4**2)+(90*1**2))/200)**0.5\n",
+ "print s"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.12, page no. 629"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 73,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A denotes the no. of persons falling in the weight group starting from (70−80)... till (140−150)\n",
+ "The second row denotes cumulative frequency\n",
+ "Median falls in the class (110−120) = l+((n/2−c)∗h)/f= 111\n",
+ "Lower quartile also falls in the class (90−100)= 97.8571428571\n",
+ "Upper quartile also falls in the class (120−130)= 123.444444444\n",
+ "Quartile coefficient of skewness= -0.0272952853598\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([2,8])\n",
+ "print \"The first row of A denotes the no. of persons falling in the weight group starting from (70−80)... till (140−150)\"\n",
+ "A[0] = [12,18,35,42,50,45,20,8]\n",
+ "print \"The second row denotes cumulative frequency\"\n",
+ "A[1,0] = 12\n",
+ "for i in range(1,8):\n",
+ " A[1,i] = A[1,i-1]+A[0,i]\n",
+ "print \"Median falls in the class (110−120) = l+((n/2−c)∗h)/f= \",\n",
+ "Q2 = 110+(8*10)/50\n",
+ "print Q2\n",
+ "print \"Lower quartile also falls in the class (90−100)= \",\n",
+ "Q1 = 90+(57.5-30)*10/35\n",
+ "print Q1\n",
+ "print \"Upper quartile also falls in the class (120−130)= \",\n",
+ "Q3 = 120+(172.5-157)*10/45\n",
+ "print Q3\n",
+ "print \"Quartile coefficient of skewness= \",(Q1+Q3-2*Q2)/(Q3-Q1)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 23.13, page no. 631"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 76,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The first row of A denotes the corresponding I.R. of students \n",
+ "The second row denotes the corresponding deviation of I.R.\n",
+ "The third row denotes the square of corresponding deviation of I.R.\n",
+ "The fourth row denotes the corresponding E.R. of students \n",
+ "The fifth row denotes the corresponding deviation of E.R.\n",
+ "The sixth row denotes the square of corresponding deviation of E.R.\n",
+ "The seventh row denotes the product of the two corresponding deviations\n",
+ "[[ 105. 104. 102. 101. 100. 99. 98. 96. 93. 92.]\n",
+ " [ 6. 5. 3. 2. 1. 0. -1. -3. -6. -7.]\n",
+ " [ 36. 25. 9. 4. 1. 0. 1. 9. 36. 49.]\n",
+ " [ 101. 103. 100. 98. 95. 96. 104. 92. 97. 94.]\n",
+ " [ 3. 5. 2. 0. -3. -2. 6. -6. -1. -4.]\n",
+ " [ 9. 25. 4. 0. 9. 4. 36. 36. 1. 16.]\n",
+ " [ 18. 25. 6. 0. -3. -0. -6. 18. 6. 28.]]\n",
+ "The sum of elements of first row=a = 990.0\n",
+ "The sum of elements of second row=b = 0.0\n",
+ "The sum of elements of third row=c = 170.0\n",
+ "The sum of elements of fourth row=d = 980.0\n",
+ "The sum of elements of fifth row=e = 0.0\n",
+ "The sum of elements of sixth row=d = 140.0\n",
+ "The sum of elements of seventh row=d = 92.0\n",
+ "Coefficient of correlation = 0.596347425668\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "\n",
+ "A = numpy.zeros([7,10])\n",
+ "print \"The first row of A denotes the corresponding I.R. of students \"\n",
+ "A[0] = [105,104,102,101,100,99,98,96,93,92]\n",
+ "print \"The second row denotes the corresponding deviation of I.R.\"\n",
+ "for i in range(0,10):\n",
+ " A[1,i] = A[0,i]-99\n",
+ "print \"The third row denotes the square of corresponding deviation of I.R.\"\n",
+ "for i in range(0,10):\n",
+ " A[2,i] = A[1,i]**2\n",
+ "print \"The fourth row denotes the corresponding E.R. of students \"\n",
+ "A[3] = [101,103,100,98,95,96,104,92,97,94]\n",
+ "print \"The fifth row denotes the corresponding deviation of E.R.\"\n",
+ "for i in range(0,10):\n",
+ " A[4,i] = A[3,i]-98\n",
+ "print \"The sixth row denotes the square of corresponding deviation of E.R.\"\n",
+ "for i in range(0,10):\n",
+ " A[5,i] = A[4,i]**2\n",
+ "print \"The seventh row denotes the product of the two corresponding deviations\"\n",
+ "for i in range(0,10):\n",
+ " A[6,i] = A[1,i]*A[4,i]\n",
+ "print A\n",
+ "a = 0\n",
+ "print \"The sum of elements of first row=a = \",\n",
+ "for i in range(0,10):\n",
+ " a = a+A[0,i]\n",
+ "print a\n",
+ "b = 0 \n",
+ "print \"The sum of elements of second row=b = \",\n",
+ "for i in range(0,10):\n",
+ " b = b+A[1,i]\n",
+ "print b\n",
+ "c = 0\n",
+ "print \"The sum of elements of third row=c = \",\n",
+ "for i in range(0,10):\n",
+ " c = c+A[2,i]\n",
+ "print c\n",
+ "d = 0\n",
+ "print \"The sum of elements of fourth row=d = \",\n",
+ "for i in range(0,10):\n",
+ " d = d+A[3,i]\n",
+ "print d\n",
+ "e = 0\n",
+ "print \"The sum of elements of fifth row=e = \",\n",
+ "for i in range(0,10):\n",
+ " e = e+A[4,i]\n",
+ "print e\n",
+ "f = 0\n",
+ "print \"The sum of elements of sixth row=d = \",\n",
+ "for i in range(0,10):\n",
+ " f = f+A[5,i]\n",
+ "print f\n",
+ "g = 0\n",
+ "print \"The sum of elements of seventh row=d = \",\n",
+ "for i in range(0,10):\n",
+ " g = g+A[6,i]\n",
+ "print g\n",
+ "print \"Coefficient of correlation = \",g/(c*f)**0.5"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 2",
+ "language": "python",
+ "name": "python2"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 2
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython2",
+ "version": "2.7.10"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}