{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Basic Of Measurement And Error Analysis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.1\n",
      " : Page No - 2.7 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "# Values of measurements\n",
      "x1 = 49 \n",
      "x2 = 51 \n",
      "x3 = 52 \n",
      "x4 = 50 \n",
      "x5 = 49 \n",
      "n = 5 # numbers of reading\n",
      "Xn_bar = (x1+x2+x3+x4+x5)/n # average value for the set of measurements\n",
      "# For n = 3\n",
      "P = 1 - abs( (x3-Xn_bar)/x3) # the value of third measurement\n",
      "P = P * 100 # in %\n",
      "print \"The precision of the 3rd measurement = %0.1f %% \" %P"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The precision of the 3rd measurement = 96.5 % \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.2\n",
      " : Page No - 2.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "At = 150 # in V\n",
      "Am = 149 # in V\n",
      "e = At-Am #absolute error in V\n",
      "print \"The absolute error = %0.f V \" %e\n",
      "e_r = ((At-Am)/At)*100 # e_r stands for %e_r in %\n",
      "print \"The percentage error = %0.2f %% \" %e_r\n",
      "A = 1 - abs( (At-Am)/At ) # relative accuracy\n",
      "print \"The Relative accuracy = %0.4f \" %A\n",
      "a = A*100 #Relative accuracy  in %\n",
      "print \"The percentage accuracy = %0.2f %% \" %a\n",
      "fsd = 200 #full scale reading in V\n",
      "# Percentage error \n",
      "PerError = ((At-Am)/fsd)*100 # in %\n",
      "print \"Percentage error expressed as percentage of full scale reading = %0.1f %% \" %PerError"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The absolute error = 1 V \n",
        "The percentage error = 0.67 % \n",
        "The Relative accuracy = 0.9933 \n",
        "The percentage accuracy = 99.33 % \n",
        "Percentage error expressed as percentage of full scale reading = 0.5 % \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.3\n",
      " : Page No - 2.11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "ChangeInOutput= 5 #change in output in mm\n",
      "ChangeInInput= 2 # change in input in A\n",
      "# Sensitivity,\n",
      "sensitivity= ChangeInOutput/ChangeInInput # in mm/A\n",
      "# Deflection factor,\n",
      "defFactor= 1/sensitivity # in A/mm\n",
      "print \"Sensitivity of the ammeter       = %0.1f mm/A\" %sensitivity\n",
      "print \"Deflection factor of the ammeter = %0.1f A/mm\" %defFactor\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Sensitivity of the ammeter       = 2.5 mm/A\n",
        "Deflection factor of the ammeter = 0.4 A/mm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.4\n",
      " : Page No - 2.11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Fullscaledeflection = 30 #full scale deflection in cm\n",
      "n = 30 # number of divisions\n",
      "scaledivision = Fullscaledeflection/n #scale division in cm\n",
      "scaledivision = scaledivision * 10 # in mm\n",
      "Resolution = (1/20)*scaledivision # in mm\n",
      "print \"The Resolution of the scale = %0.1f mm \" %Resolution"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Resolution of the scale = 0.5 mm \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.5\n",
      " : Page No - 2.29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "import numpy as np\n",
      "#Given data\n",
      "# Reported values for average petrol consumption\n",
      "x= [25.5,30.3, 31.1, 29.6, 32.4, 39.4, 28.9, 30.0, 33.3, 31.4, 29.5, 30.5, 31.7, 33.0, 29.2] \n",
      "n = 15 # number of reading\n",
      "sigma_x=0 # initialization of variable\n",
      "for i in range(0,15) :\n",
      "    sigma_x= sigma_x+x[i] # sum of reading\n",
      "\n",
      "Mean =sigma_x/n # mean value\n",
      "print \"The mean value         = %0.4f \" %Mean\n",
      "sorted_x= np.sort(x) \n",
      "Xmedian = sorted_x[(n+1)/2-1] # median value\n",
      "print \"The median value       = %0.1f \" %Xmedian\n",
      "sigma_d_sq=0 \n",
      "d= [None]*15\n",
      "for i in range(0,15) :\n",
      "    d[i]=x[i]-Mean\n",
      "    sigma_d_sq= sigma_d_sq+d[i]*d[i] \n",
      "\n",
      "sigma = round(sqrt( sigma_d_sq/(n-1))) # standard deviation\n",
      "print \"The standard deviation = %0.2f \" %sigma\n",
      "V = sigma**2 # variance\n",
      "print \"The variance           = %0.2f \" %V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean value         = 31.0533 \n",
        "The median value       = 30.5 \n",
        "The standard deviation = 3.00 \n",
        "The variance           = 9.00 \n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.6\n",
      " : Page No - 2.30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "# Value of readings\n",
      "x=[147.2, 147.4, 147.9, 148.1, 147.7, 147.5, 147.6, 147.4, 147.6, 147.5] \n",
      "n = 10 # number of reading\n",
      "sigma_x=0 # initialization of variable\n",
      "for i in range(0,n) :\n",
      "    sigma_x= sigma_x+x[i] # sum of readings\n",
      "\n",
      "x_bar= sigma_x/n # mean value \n",
      "print \"The arthmatic mean = %0.2f \" %x_bar\n",
      "sigma_d_sq=0 \n",
      "d= [None]*n\n",
      "for i in range(0,n) :\n",
      "    d[i]=x[i]-x_bar \n",
      "    sigma_d_sq= sigma_d_sq+d[i]*d[i] \n",
      "sigma = sqrt( sigma_d_sq/(n-1) ) # standard deviation \n",
      "print \"The standard deviation = %0.4f \" %sigma\n",
      "# probable error of average of the ten reading \n",
      "e_m = 0.6745 * ( sigma/(sqrt(n-1)) ) \n",
      "print \"The probable error of average of the ten reading = %0.6f \" %e_m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The arthmatic mean = 147.59 \n",
        "The standard deviation = 0.2601 \n",
        "The probable error of average of the ten reading = 0.058485 \n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.7\n",
      " : Page No - 2.32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Vrange=50 #range of voltmeter in V\n",
      "V= 15 #instrument reading in V\n",
      "# Limiting error at full scale\n",
      "del_A= Vrange*1/100 # in V\n",
      "# limiting error \n",
      "PerE= del_A/V*100 # in %\n",
      "print \"The limiting error = %0.2f %% \" %PerE"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The limiting error = 3.33 % \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.8\n",
      " : Page No - 2.36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "del_a1 = 0.02 # limiting error in current\n",
      "del_a2 = 0.5 # limiting error in resistor\n",
      "A1 = 2 \n",
      "A2 = 120 \n",
      "e1 = del_a1/A1 \n",
      "e2 = del_a2/A2 \n",
      "n = 2 \n",
      "# limiting error \n",
      "e_T = (n*e1)+e2 \n",
      "e_T_Per= e_T*100 # limiting error in percentage\n",
      "print \"The limiting error = \u00b1\",round(e_T,5),\"or \u00b1\",round(e_T_Per,3),\"%\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The limiting error = \u00b1 0.02417 or \u00b1 2.417 %\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.9\n",
      " : Page No - 2.37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1= 15 #value of resistance in \u03a9\n",
      "Re1= R1*5/100 #error in resistance in \u03a9\n",
      "R2= 33 #value of resistance in \u03a9\n",
      "Re2= R2*2/100 #error in resistance in \u03a9\n",
      "R3= 75 #value of resistance in \u03a9\n",
      "Re3= R3*5/100 #error in resistance in \u03a9\n",
      "R_T= R1+R2+R3 #resultant resistance in \u03a9\n",
      "R_T_e= Re1+Re2+Re3 #limiting error in resistance in \u03a9\n",
      "print \"The resultant = \",int(R_T),\"\u03a9 with the limiting error of \",round(R_T_e,2),\"\u03a9\"\n",
      "e_T= R_T_e/R_T*100 # in %\n",
      "print \"The percentage relative limiting error in resultant = \u00b1\",round(e_T,1),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant =  123 \u03a9 with the limiting error of  5.16 \u03a9\n",
        "The percentage relative limiting error in resultant = \u00b1 4.2 %\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.10\n",
      " : Page No - 2.39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "#Given data\n",
      "R1= 100 #resistance in \u03a9\n",
      "Re1= 0.1 #error in \u03a9\n",
      "R2= 50 #resistance in \u03a9\n",
      "Re2= 0.03 #error in \u03a9\n",
      "R= R1+R2 #resistance in \u03a9\n",
      "w= sqrt(Re1**2+Re2**2) \n",
      "print \"For Series connection, R   =\",int(R),\"\u00b1\",round(w,4),\"\u03a9\"\n",
      "R= R1*R2/(R1+R2) # in \u03a9\n",
      "del_RbyR1= ((R1+R2)*R2-R1*R2)/(R1+R2)**2 \n",
      "del_RbyR2= ((R1+R2)*R1-R1*R2)/(R1+R2)**2 \n",
      "w= sqrt(del_RbyR1**2*Re1**2+del_RbyR2**2*Re2**2) \n",
      "print \"For Parallel connection, R =\",round(R,2),\"\u00b1\",round(w,5),\"\u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For Series connection, R   = 150 \u00b1 0.1044 \u03a9\n",
        "For Parallel connection, R = 33.33 \u00b1 0.01736 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.11\n",
      " : Page No - 2.39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "At = 8.5 #true value in A\n",
      "Am = 8.3 #measured value in A\n",
      "Absoluteerror = At - Am #absolute error in A\n",
      "print \"The Absolute error = %0.1f A \" %Absoluteerror\n",
      "# Relative percentage error \n",
      "Per_Error = ((At-Am)/At)*100 # %e in %\n",
      "print \"The relative percentage error = %0.2f %% \" %Per_Error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Absolute error = 0.2 A \n",
        "The relative percentage error = 2.35 % \n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.12\n",
      " : Page No - 2.40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Am = 111.5 #measured value in V\n",
      "Per_Error = 5.3 # %e in %\n",
      "# Per_Error = ((At-Am)/At)*100 \n",
      "At = Am/(1 - (Per_Error/100)) #true value of voltage  in V\n",
      "print \"The true value of voltage = %0.2f V \" %At"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The true value of voltage = 117.74 V \n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.13\n",
      " : Page No - 2.40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "fullscaledivision = 100 #full scale division in V\n",
      "n = 200 #number of divisions\n",
      "scaledivision = fullscaledivision/n #scale division in V\n",
      "Resolution = 1/2*scaledivision # in V\n",
      "print \"The Resolution of meter = %0.2f V \" %Resolution"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Resolution of meter = 0.25 V \n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.14\n",
      " : Page No - 2.40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "V = 150 #voltage in V\n",
      "R1 = 50 #resistance in k ohm\n",
      "R2 = 100 #resistance in k ohm\n",
      "V_AB = R1 * (V/(R1+R2)) # in V\n",
      "sensitivity = 1 # in k ohm/V\n",
      "R = sensitivity*V_AB # in  k ohm\n",
      "V_AB1 = ((R1*R)/(R1+R))*( V/(R2+(R1*R)/(R1+R)) ) #voltage reading on the voltmeter  in V\n",
      "print \"Part (i) When voltmeter sensitivity is 1 k\u03a9/volt : \"\n",
      "print \"The voltage reading on the voltmeter = %0.f V \" %V_AB1\n",
      "Per_Error= ((V_AB-V_AB1)/V_AB)*100 # %e in %\n",
      "print \"The percentage error = +%0.f %% \" %Per_Error\n",
      "sensitivity = 25 # in  k ohm/V\n",
      "R = sensitivity*V_AB # in k ohm\n",
      "Rnet = (R1*R)/(R1+R) # assumed for calculation\n",
      "V_AB2 = Rnet*( V/(R2+Rnet) ) # in V\n",
      "print \"Part (ii) When voltmeter sensitivity is 25 k\u03a9/volt : \"\n",
      "print \"The voltage reading on the voltmeter = %0.3f V \" %V_AB2\n",
      "Per_Error = ((V_AB-V_AB2)/V_AB)*100 # %e in %\n",
      "print \"The percentage error = %0.2f %% \" %Per_Error\n",
      "print \"Thus the voltmeter with low sensitivity shows more error\"\n",
      "print \" while voltmeter with high sensitivity shows less error.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (i) When voltmeter sensitivity is 1 k\u03a9/volt : \n",
        "The voltage reading on the voltmeter = 30 V \n",
        "The percentage error = +40 % \n",
        "Part (ii) When voltmeter sensitivity is 25 k\u03a9/volt : \n",
        "The voltage reading on the voltmeter = 48.701 V \n",
        "The percentage error = 2.60 % \n",
        "Thus the voltmeter with low sensitivity shows more error\n",
        " while voltmeter with high sensitivity shows less error.\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.15\n",
      " : Page No - 2.42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "V = 80 # in V\n",
      "I = 15 # in mA\n",
      "I = I * 10**-3 # in A\n",
      "R_T = V/I # in ohm\n",
      "R_T = R_T * 10**-3 #apparent resistance in k ohm\n",
      "Rapp = R_T # in k ohm\n",
      "print \"The apparent resistance = %0.3f k\u03a9 \" %Rapp\n",
      "sensitivity = 1.5 # in k ohm\n",
      "f_s_reading = 150 #full scale reading in V\n",
      "Rv = sensitivity*f_s_reading # in k ohm\n",
      "#R_T = (Rx*Rv)/(Rx+Rv) \n",
      "Rx = (R_T*Rv)/(Rv-R_T) #Actual resistance of unknown resistor in k ohm\n",
      "print \"Actual resistance of unknown resistor = %0.3f k\u03a9 \" %Rx\n",
      "At = Rx # in k ohm\n",
      "Am = Rapp # in k ohm\n",
      "PerError = ((At-Am)/At)*100 #Error due to loading effect of voltmeter  in %\n",
      "print \"Error due to loading effect of voltmeter = %0.2f %% \" %PerError\n",
      "PerAccu = (1-abs(PerError*10**-2))*100 #Percentage relative accuracy  in %\n",
      "print \"Percentage relative accuracy = %0.2f %% \" %PerAccu"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The apparent resistance = 5.333 k\u03a9 \n",
        "Actual resistance of unknown resistor = 5.463 k\u03a9 \n",
        "Error due to loading effect of voltmeter = 2.37 % \n",
        "Percentage relative accuracy = 97.63 % \n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.16\n",
      " : Page No - 2.43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "# Values of resistance\n",
      "R1 = 200 # in ohm\n",
      "R2 = 100 # in  ohm\n",
      "R3 = 50 # in ohm\n",
      "R_T = R1+R2+R3 #resultant resistance in ohm\n",
      "# Error in resistance\n",
      "e1 = 5 # in %\n",
      "e2 = e1 # in %\n",
      "e3 = e1 # in %\n",
      "a1 = R1 # in ohm\n",
      "a2 = R2 # in ohm\n",
      "a3 = R3 # in ohm\n",
      "Per_e_T = ( ((R1/R_T)*e1) + ((R2/R_T)*e2) + ((R3/R_T)*e3) ) # in %\n",
      "# Per_e_T= del_R_T/R_T*100 \n",
      "del_R_T= Per_e_T*R_T/100 # in \u03a9\n",
      "print \"The magnitude of the resultant resistance = %0.f \u03a9 \" %R_T\n",
      "print \"The limiting error (in percentage) is : \u00b1 \",int(Per_e_T),\"%\"\n",
      "print \"The limiting error (in ohm) is : \u00b1 \",round(del_R_T,1),\" \u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The magnitude of the resultant resistance = 350 \u03a9 \n",
        "The limiting error (in percentage) is : \u00b1  4 %\n",
        "The limiting error (in ohm) is : \u00b1  17.5  \u03a9\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.17\n",
      " : Page No - 2.44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "# Values of resistances\n",
      "R1 = 36 # in ohm\n",
      "R2 = 75 # in ohm\n",
      "R_T = (R1*R2)/(R1+R2) # in ohm\n",
      "# Error in resistance\n",
      "e1 = 5 # in %\n",
      "e_1 = e1+e1 # in %      assumed\n",
      "e2 = ( ((R1/(R1+R2))*e1) + ((R2/(R1+R2))*e1) ) # in %\n",
      "e_T = e_1+e2 #limiting error  in %\n",
      "# Per_e_T= del_R_T/R_T*100 \n",
      "del_R_T= e_T*R_T/100 #limiting error in \u03a9\n",
      "print \"The limiting error (in percentage) is : \u00b1\",int(e_T),\" %\"\n",
      "print \"The limiting error (in ohm) is : \u00b1\",round(del_R_T,2),\" \u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The limiting error (in percentage) is : \u00b1 15  %\n",
        "The limiting error (in ohm) is : \u00b1 3.65  \u03a9\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.18\n",
      " : Page No - 2.45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Error = 2/100 \n",
      "Voltmeterrange = 50 #voltmeter range in V\n",
      "Ammeterrange = 125 #ammeter range in mA\n",
      "A1 = 40 #voltmeter reading in V\n",
      "A2 = 125 #ammeter reading in mA\n",
      "del_a1 = Error*Voltmeterrange # in V\n",
      "del_a2 = Error*Ammeterrange # in mA\n",
      "e1 =  del_a1/A1 # error in voltage\n",
      "e2 = del_a2/A2 # error in current\n",
      "e_T= (e1+e2)*100 #limiting error of the power calculated  in %\n",
      "print \"The limiting error of the power calculated is : \u00b1\",round(e_T,1),\" %\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The limiting error of the power calculated is : \u00b1 4.5  %\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.19\n",
      " : Page No - 2.46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 120 #resistance in ohm\n",
      "e1= 0.1 #error in %\n",
      "R2 = 2700 #resistance in ohm\n",
      "e2= 0.5 #error in %\n",
      "R3 = 470 #resistance in ohm\n",
      "e3= 0.5 #error in %\n",
      "Rx = (R2*R3)/R1 #magnitude of the unknown resistance in ohm\n",
      "print \"The magnitude of the unknown resistance = %0.f \u03a9 \" %Rx\n",
      "e_T= e1+e2+e3 #limiting error  in %\n",
      "# Per_e_T= del_R_T/R_T*100 \n",
      "del_Rx= e_T*Rx/100 #limiting error  in \u03a9\n",
      "print \"The limiting error (in percentage) is : \u00b1 \",round(e_T,1),\"%\"\n",
      "print \"The limiting error (in ohm) is : \u00b1 \",round(del_Rx,3),\"\u03a9\"\n",
      "print \"Hence the guaranteed values of the resistance is between\",round(Rx-del_Rx,3),\" \u03a9 to \",round(Rx+del_Rx,3),\"\u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The magnitude of the unknown resistance = 10575 \u03a9 \n",
        "The limiting error (in percentage) is : \u00b1  1.1 %\n",
        "The limiting error (in ohm) is : \u00b1  116.325 \u03a9\n",
        "Hence the guaranteed values of the resistance is between 10458.675  \u03a9 to  10691.325 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.20\n",
      " : Page No - 2.47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "x=[101.2, 101.4, 101.7, 101.3, 101.3, 101.2, 101.0, 101.3, 101.5, 101.1] # measured value\n",
      "n = 10 # number of reading\n",
      "sigma_x= 0 # initialization of variable\n",
      "for i in range(0,n) :\n",
      "    sigma_x= sigma_x+x[i] # sum of readings\n",
      "\n",
      "x_bar=sigma_x/n # mean value\n",
      "print \"The arithmatic mean = %0.1f \" %x_bar\n",
      "sigma_d_sq=0 # initialization of variable\n",
      "sigma_d=0 # initialization of variable\n",
      "d= [None]*n\n",
      "for i in range(0,n) :\n",
      "    d[i]=x[i]-x_bar\n",
      "    sigma_d= sigma_d+abs(d[i]) \n",
      "    sigma_d_sq= sigma_d_sq+d[i]*d[i] \n",
      "\n",
      "DevFrommean =sigma_d/n # Deviation from mean \n",
      "print \"The Deviation from mean = %0.2f \" %DevFrommean\n",
      "sigma = sqrt( sigma_d_sq/(n-1) ) #standard deviation  in V\n",
      "print \"The standard deviation = %0.1f V \" %sigma\n",
      "ProError= 0.6745*sigma #probable error of one reading  in V\n",
      "print \"The probable error of one reading = %0.4f V \" %ProError\n",
      "ProError = 0.6745*sigma # in V\n",
      "e_m = ProError/( sqrt(n-1) ) # probable error of mean \n",
      "print \"The probable error of mean = %0.4f \" %e_m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The arithmatic mean = 101.3 \n",
        "The Deviation from mean = 0.14 \n",
        "The standard deviation = 0.2 V \n",
        "The probable error of one reading = 0.1349 V \n",
        "The probable error of mean = 0.0450 \n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.21\n",
      " : Page No - 2.48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "#Given data\n",
      "x= [29.6, 32.4, 39.4, 28.9, 30.0, 33.3, 31.4, 29.5, 30.5, 31.7, 33.0, 29.2] # measured value\n",
      "n = 12 # number of reading\n",
      "sigma_x= 0 # initialization of variable\n",
      "for i in range(0,n) :\n",
      "    sigma_x= sigma_x+x[i] # sum of readings\n",
      "\n",
      "x_bar=sigma_x/n # mean value \n",
      "print \"The mean value = %0.3f \" %x_bar\n",
      "sorted_x= np.sort(x) \n",
      "x_median= (sorted_x[n/2]+sorted_x[n/2-1])/2 # median value\n",
      "\n",
      "print \"The median value = %0.2f \" %x_median\n",
      "sigma_d_sq=0 \n",
      "d= [None]*n\n",
      "for i in range(0,n) :\n",
      "    d[i]=x[i]-x_bar\n",
      "    sigma_d_sq= sigma_d_sq+d[i]*d[i] \n",
      "\n",
      "sigma = sqrt( sigma_d_sq/(n-1) ) #standard deviation in V\n",
      "print \"The standard deviation = %0.4f V \" %sigma"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean value = 31.575 \n",
        "The median value = 30.95 \n",
        "The standard deviation = 2.8857 V \n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.22\n",
      " : Page No - 2.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "x= [41.7, 42.0, 41.8, 42.0, 42.1, 41.9, 42.0, 41.9, 42.5, 41.8] # measured value\n",
      "n = 10 # number of reading\n",
      "sigma_x= 0 # initialization of variable\n",
      "for i in range(0,n) :\n",
      "    sigma_x= sigma_x+x[i] # sum of reading\n",
      "\n",
      "x_bar=sigma_x/n # mean\n",
      "print \"The mean = %0.2f \" %x_bar\n",
      "sigma_d_sq=0 \n",
      "d= [None]*n \n",
      "for i in range(0,n) :\n",
      "    d[i]=x[i]-x_bar\n",
      "    sigma_d_sq= sigma_d_sq+d[i]*d[i] \n",
      "\n",
      "sigma = sqrt( sigma_d_sq/(n-1) ) #standard deviation in V\n",
      "print \"The standard deviation = %0.6f V \" %sigma\n",
      "ProError= 0.6745*sigma #probable error of one reading in V\n",
      "print \"The probable error of one reading = %0.4f V \" %ProError\n",
      "ProError = 0.6745*sigma # in V\n",
      "e_m = ProError/( sqrt(n-1) ) # probable error of mean\n",
      "print \"The probable error of mean = %0.5f \" %e_m\n",
      "sorted_x= np.sort(x) \n",
      "Range= sorted_x[0]-sorted_x[n-1] # range\n",
      "print \"Range = \",round(sorted_x[0],1),\" to \",round(sorted_x[n-1],1),\" = \",round(Range,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean = 41.97 \n",
        "The standard deviation = 0.221359 V \n",
        "The probable error of one reading = 0.1493 V \n",
        "The probable error of mean = 0.04977 \n",
        "Range =  41.7  to  42.5  =  -0.8\n"
       ]
      }
     ],
     "prompt_number": 58
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.23\n",
      " : Page No - 2.50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Vrange= 600 #range in V\n",
      "del_A= 2.5*Vrange/100 #limiting error at full scale in V\n",
      "V= 400 #voltage in V\n",
      "PerError= del_A/V*100 #percentage error in %\n",
      "print \"The limiting error is : \u00b1\",round(PerError,2),\" %\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The limiting error is : \u00b1 3.75  %\n"
       ]
      }
     ],
     "prompt_number": 57
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.24\n",
      " : Page No - 2.50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "At = 6.54 #true value in A\n",
      "Am = 6.7 #measured value in A\n",
      "AbsError = At-Am # absolute error\n",
      "PerError= ((At-Am)/At)*100 # percentage error\n",
      "print \"The error = %0.3f %% \" %PerError"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The error = -2.446 % \n"
       ]
      }
     ],
     "prompt_number": 59
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 2.25\n",
      " : Page No - 2.51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Wrange= 500 #wattmeter range in W\n",
      "del_A= 1.5*Wrange/100 #limiting error at full scale in W\n",
      "P= 50 #power in W\n",
      "Pmin= P-del_A # minimum power in W\n",
      "Pmax= P+del_A # maximum power in W\n",
      "print \"The range of the reading =\",round(Pmin,1),\"watts to\",round(Pmax,1),\"watts\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The range of the reading = 42.5 watts to 57.5 watts\n"
       ]
      }
     ],
     "prompt_number": 63
    }
   ],
   "metadata": {}
  }
 ]
}