summaryrefslogtreecommitdiff
path: root/sample_notebooks/Vishwajith VRao/Chapter2.ipynb
diff options
context:
space:
mode:
authorhardythe12015-05-05 14:21:39 +0530
committerhardythe12015-05-05 14:21:39 +0530
commit435840cef00c596d9e608f9eb2d96f522ea8505a (patch)
tree4c783890c984c67022977ca98432e5e4bab30678 /sample_notebooks/Vishwajith VRao/Chapter2.ipynb
parentaa1863f344766ca7f7c20a395e58d0fb23c52130 (diff)
downloadPython-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.tar.gz
Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.tar.bz2
Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.zip
add books
Diffstat (limited to 'sample_notebooks/Vishwajith VRao/Chapter2.ipynb')
-rwxr-xr-xsample_notebooks/Vishwajith VRao/Chapter2.ipynb350
1 files changed, 350 insertions, 0 deletions
diff --git a/sample_notebooks/Vishwajith VRao/Chapter2.ipynb b/sample_notebooks/Vishwajith VRao/Chapter2.ipynb
new file mode 100755
index 00000000..afc828c0
--- /dev/null
+++ b/sample_notebooks/Vishwajith VRao/Chapter2.ipynb
@@ -0,0 +1,350 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1>Chapter 2:MEASUREMENT ERRORS<h1>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h2>Example 2-1, Page number: 16<h2>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 101,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Tolerance of the resistance= +/- 5 %\n",
+ "Maximum Resistance at 75 degree celsius= 1.2915 kilo ohm\n"
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "#Resistance Values at 25 degree Celsius\n",
+ "rmax25=1.26*10**3\n",
+ "rmin25=1.14*10**3\n",
+ "r=1.2*10**3\n",
+ "ppm=500.0/1000000\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "absolute_error=rmax-r\n",
+ "\n",
+ "#Tolerance value in percentage\n",
+ "tolerance=absolute_error/r*100\n",
+ "\n",
+ "#Resistance per degree Celsius\n",
+ "rperc=rmax*ppm\n",
+ "\n",
+ "\n",
+ "#To Calculate ressistance at 75 degree celsius\n",
+ "\n",
+ "dT=75-25\n",
+ "\n",
+ "dR=rperc*dT\n",
+ "\n",
+ "#Maximum resistance at 75 degree celsius\n",
+ "\n",
+ "rmax75=rmax+dR\n",
+ "\n",
+ "\n",
+ "#Results\n",
+ "print 'Tolerance of the resistance= +/-',int(tolerance),'%'\n",
+ "print 'Maximum Resistance at 75 degree celsius=',round(rmax75/1000,4),'kilo ohm'\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "<h2>Example 2-2, Page number: 20<h2>\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 94,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Maximum percentage error= 2.8 %\n",
+ "V=( 180 V +/- 2.8 %)\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Variable Declaration\n",
+ "\n",
+ "V1=100 \n",
+ "V2=80\n",
+ "p1=1.0/100 #Percentage error of V1\n",
+ "p2=5.0/100 #Percentage error of V2\n",
+ "\n",
+ "\n",
+ "#Calculations\n",
+ "V1max=V1+V1*p1\n",
+ "V2max=V2+V2*p2\n",
+ "\n",
+ "\n",
+ "Emax=V1max+V2max\n",
+ "E=V1+V2\n",
+ "\n",
+ "p=100*(Emax-E)/E\n",
+ "\n",
+ "#Results\n",
+ "print 'Maximum percentage error=',round(p,1),'%'\n",
+ "print 'V=(',E,'V +/-',round(p,1),'%)'\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h2>Example 2-3, Page number: 22<h2>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 100,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Maximum percentage error= +/- 25 %\n",
+ "Voltage=( 20 V +/- 25 %)\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Variable Declaration\n",
+ "\n",
+ "V1=100\n",
+ "V2=80\n",
+ "p1=1.0/100 #Percentage error of V1\n",
+ "p2=5.0/100 #Percentage error of V2\n",
+ "\n",
+ "\n",
+ "#Calculations\n",
+ "E=V1-V2\n",
+ "V1max=V1+V1*p1\n",
+ "V2min=V2-V2*p2\n",
+ "Emax=V1max-V2min\n",
+ "\n",
+ "p=100*(Emax-E)/E\n",
+ "\n",
+ "#Results\n",
+ "print 'Maximum percentage error= +/-',int(p),'%'\n",
+ "print 'Voltage=(',E,'V +/-',int(p), '%)'\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h2>Example 2-4, Page number: 23<h2>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 98,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Power= 82 mW\n",
+ "Percentage error in power= +/- 20 %\n",
+ "Power=( 82 mW +/- 20 %)\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Variable Declaration\n",
+ "r=820 #Resistance\n",
+ "r_accuracy=10.0/100 #Accuracy of r in percentage\n",
+ "I=10*10**(-3) #Current\n",
+ "I_accuracy=2.0/100 #Accuracy of I at Full scale in percentage\n",
+ "Imax=25*10**(-3) #Full scale current\n",
+ "\n",
+ "#Calculations\n",
+ "power=r*(I**2)\n",
+ "\n",
+ "I_error=I_accuracy*Imax\n",
+ "\n",
+ "I_error_percentage=100*I_error/(10*10**(-3))\n",
+ "\n",
+ "Isquare_error=2*I_error_percentage\n",
+ "\n",
+ "p_error=Isquare_error+(r_accuracy*100)\n",
+ "\n",
+ "\n",
+ "\n",
+ "#Results\n",
+ "print 'Power=',int(power*1000),' mW'\n",
+ "print 'Percentage error in power= +/-',int(p_error), '%'\n",
+ "print 'Power=(',int(power*1000),'mW +/-',int(p_error),'%)'\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h2>Example 2-5, Page Number: 25<h2>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 78,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Average Deviation= 0.0012 volt\n"
+ ]
+ }
+ ],
+ "source": [
+ "import math\n",
+ "\n",
+ "#Variable Declaration\n",
+ "V=[1.001,1.002,0.999,0.998,1.000] #Voltage readings\n",
+ "v_average=0.0 #Variable to hold average value\n",
+ "d=[0]*5 #Array of 5 elements to hold deviation\n",
+ "D_average=0.0 #Variable to hold average deviation\n",
+ "\n",
+ "#Calculation\n",
+ "for i in range(0,5):\n",
+ " v_average=v_average+V[i]\n",
+ " \n",
+ "v_average=v_average/5.0\n",
+ "\n",
+ "for i in range(0,5):\n",
+ " d[i]=V[i]-v_average\n",
+ " \n",
+ "for i in range(0,5):\n",
+ " D_average=D_average+math.fabs(d[i])\n",
+ "\n",
+ "D_average=D_average/5\n",
+ "\n",
+ "print 'Average Deviation=',round(D_average,5),'volt'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h2>Example 2-6, Page number: 26<h2>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 89,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Standard Deviation= 0.0014 V\n",
+ "Probable Error= 0.94 mV\n"
+ ]
+ }
+ ],
+ "source": [
+ "import math\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "V=[1.001,1.002,0.999,0.998,1.000] #Voltage readings\n",
+ "v_average=0.0 #Variable to hold average value\n",
+ "d=[0]*5 #Array of 5 elements to hold deviation\n",
+ "D_average=0.0 #Variable to hold average deviation\n",
+ "std_deviation=0.0\n",
+ "\n",
+ "#Calculation\n",
+ "for i in range(0,5):\n",
+ " v_average=v_average+V[i]\n",
+ " \n",
+ "v_average=v_average/5.0\n",
+ "\n",
+ "for i in range(0,5):\n",
+ " d[i]=V[i]-v_average\n",
+ " \n",
+ "for i in range(0,5):\n",
+ " std_deviation=std_deviation+d[i]**2\n",
+ "\n",
+ "std_deviation=math.sqrt(std_deviation/5)\n",
+ "\n",
+ "probable_error=0.6745*round(std_deviation,4)\n",
+ "print 'Standard Deviation=',round(std_deviation,4),'V'\n",
+ "print 'Probable Error=',round(probable_error*1000,2),'mV'"
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}