summaryrefslogtreecommitdiff
path: root/sample_notebooks/VineshSaini/ch1.ipynb
blob: 338df5a05bb26c91d745d17016a718582b140f88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
{
 "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": {}
  }
 ]
}