summaryrefslogtreecommitdiff
path: root/sample_notebooks/Vishwajith VRao/Chapter2_1.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_1.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_1.ipynb')
-rwxr-xr-xsample_notebooks/Vishwajith VRao/Chapter2_1.ipynb348
1 files changed, 348 insertions, 0 deletions
diff --git a/sample_notebooks/Vishwajith VRao/Chapter2_1.ipynb b/sample_notebooks/Vishwajith VRao/Chapter2_1.ipynb
new file mode 100755
index 00000000..f9cef862
--- /dev/null
+++ b/sample_notebooks/Vishwajith VRao/Chapter2_1.ipynb
@@ -0,0 +1,348 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 2: MEASUREMENT ERRORS \n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example 2-1, Page Number: 16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "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": [
+ "#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=rmax25-r\n",
+ "\n",
+ "#Tolerance value in percentage\n",
+ "tolerance=absolute_error/r*100\n",
+ "\n",
+ "#Resistance per degree Celsius\n",
+ "rperc=rmax25*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=rmax25+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"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "##Example 2-2, Page Number: 20\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "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": [
+ "##Example 2-3, Page Number: 22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "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": [
+ "##Example 2-4, Page Number: 23"
+ ]
+ },
+ {
+ "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": [
+ "##Example 2-5, Page Number: 25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "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": [
+ "##Example 2-6, Page Number: 26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "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
+}