{
 "metadata": {
  "name": "",
  "signature": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 01 : Standards, Units & Dimensions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.17 : page 56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Y=90.0 \n",
      "X=89.0 \n",
      "Error_absolute=Y-X \n",
      "print 'absolute Error =',Error_absolute\n",
      "Error_relative=(Y-X)*100/Y \n",
      "print 'relative Error =',round(Error_relative,2),'%'\n",
      "Accuracy_relative=1-Error_relative \n",
      "print 'Accuracy relative =',round(Accuracy_relative,2)\n",
      "Accuracy_percentage=100*Accuracy_relative \n",
      "print 'Accuracy =',round(Accuracy_percentage,2),'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "absolute Error = 1.0\n",
        "relative Error = 1.11 %\n",
        "Accuracy relative = -0.11\n",
        "Accuracy = -11.11 %\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.18 : page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "S=98+100+102+98+100+100+104+104+105+97 \n",
      "n=10 \n",
      "Avg=S/n \n",
      "P=1-abs((104-Avg)/Avg) \n",
      "print \"Precision for the 8th reading=%.2f\"%P"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Precision for the 8th reading=0.97\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.19 : page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "V=10 \n",
      "I=20*10**-3 \n",
      "RI=50 \n",
      "R=(V/I)-RI \n",
      "print \"The value of Resistance = %.0f ohm\"%R \n",
      "dV=0.2 \n",
      "dI=1*10**-3 \n",
      "dRI=5 \n",
      "dR=(dV/I)+(V*dI/I**2)+(dRI)\n",
      "print \"Limiting error of resistance = %.0f ohm\"%dR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Resistance = 450 ohm\n",
        "Limiting error of resistance = 40 ohm\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.20 : page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "R0=5 \n",
      "a=0.004 \n",
      "T=30 \n",
      "R=R0*(1+a*(T-20)) \n",
      "print \"Resistance of the wire = %.1f ohm\"%R \n",
      "#Let (dR/dR0) =b   (dR/da)=c   (dR/dT)=d\n",
      "b=(1+a*(T-20)) \n",
      "c=R0*(T-20) \n",
      "d=R0*a \n",
      "ur0=5*0.003 \n",
      "ua=0.004*0.01 \n",
      "ut=1 \n",
      "uR=(b**2*ur0**2+c**2*ua**2+d**2*ut**2)**0.5 \n",
      "print \"Uncertanity in resistance = %.2f ohm\"%uR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistance of the wire = 5.2 ohm\n",
        "Uncertanity in resistance = 0.03 ohm\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.21 : page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "X_mean=(15+20+25+30+35+45)/6 \n",
      "print \"The sample mean of the temperature=%.2f degree C\"%X_mean \n",
      "Y_mean=(1.9+1.93+1.97+2+2.01+2.01+1.94+1.95+1.97+2.02+2.02+2.04)/12*10**-6 \n",
      "print \"The sample mean of the faliure=%.6f failures/hour\"%Y_mean\n",
      "print 'from these values we get' \n",
      "a=1.80*10**-6 \n",
      "b=0.00226 \n",
      "print 'Y=1.80+0.00226x is the required least square line'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The sample mean of the temperature=28.33 degree C\n",
        "The sample mean of the faliure=0.000002 failures/hour\n",
        "from these values we get\n",
        "Y=1.80+0.00226x is the required least square line\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.22 : page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "n=2 \n",
      "k=1 \n",
      "dof=n-k \n",
      "chi_square=(3-5)**2/5+(7-5)**2/5 \n",
      "print 'Chi square value =',chi_square\n",
      "print 'From the dof and chi square value we find P=0.22'\n",
      "print 'Hence there are 22% chance that the distribution is just the result of random fluctuations and the coin may be unweighted'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Chi square value = 1.6\n",
        "From the dof and chi square value we find P=0.22\n",
        "Hence there are 22% chance that the distribution is just the result of random fluctuations and the coin may be unweighted\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.23 : page "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "X_mean=501*1/5 \n",
      "print \"Assigned Value=%.1f V\"%X_mean \n",
      "sigma=((1/(5-1))*((100.2-X_mean)**2+(100.3-X_mean)**2+(100.2-X_mean)**2+(100.2-X_mean)**2+(100.1-X_mean)**2))**0.5 \n",
      "# For 95% confidance level student factor t is 2.78'\n",
      "t=2.78 \n",
      "n=5 \n",
      "Ur=t*sigma/(n**0.5) \n",
      "print \"Uncertanity=%.3f V\"%Ur "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Assigned Value=100.2 V\n",
        "Uncertanity=0.088 V\n"
       ]
      }
     ],
     "prompt_number": 23
    }
   ],
   "metadata": {}
  }
 ]
}