#Example 1.1:#ARITHEMATIC MEAN,AVERAGE DEVIATION ,STANDARD DEVIATION AND PROBABLE ERROR
#calculate the ARITHEMATIC MEAN,AVERAGE DEVIATION ,STANDARD DEVIATION AND PROBABLE ERROR
#given
import math, numpy
T=numpy.array([99.7,99.8,99.9,100,100.1,100.2,100.3]);#VOLTS
f=numpy.array([2,8,20,40,21,6,3]);#frequency of occurence
q=numpy.array([T[0]*f[0],T[1]*f[1],T[2]*f[2],T[3]*f[3],T[4]*f[4],T[5]*f[5],T[6]*f[6]]);#
#calculations
AM=(q[0]+q[1]+q[2]+q[3]+q[4]+q[5]+q[6])/100;#arithematic mean in mm
qb=numpy.zeros(7)
for i in range(0,7):
qb[i]= T[i]-AM
Q= numpy.array([qb[0],qb[1],qb[2],qb[3],qb[4],qb[5],qb[6]]);#
AV=(-qb[0]*f[0]-qb[1]*f[1]-qb[2]*f[2]-qb[3]*f[3]+qb[4]*f[4]+qb[5]*f[5]+qb[6]*f[6])/100;#
SD=math.sqrt(((qb[0]**2*f[0])+(qb[1]**2*f[1])+(qb[2]**2*f[2])+(qb[3]**2*f[3])+(qb[4]**2*f[4])+(qb[5]**2*f[5])+(qb[6]**2*f[6]))/100);#standard deviation
r1= 0.6745*SD;#PROBABLE ERROR OF ONE READING
#results
print"arithmetic mean is (V)=",AM
print"average deviation is (V)=",AV
print"standard deviation is (V)=",round(SD,4)
print"probable error is (V)=",round(r1,4)
#Example 1.2:#APPRABET RESISTANCE AND PERCENTAGE GROSS ERROR
#calculate the APPARENT RESISTANCE AND PERCENTAGE GROSS ERROR
#given
print"when current reading is 5mA"
vr=100.;#voltmeter reading
ir=5.;#mA
#calculations and results
rt=vr/(ir);#in kilo ohms
print"apparent resistance in kilo ohms is",rt
vm=150.;#range of voltmeter
s=1.;#kilo ohms per volts sensivity
rv=s*vm;#kilo ohms
rx=((rt*rv)/(rv-rt));#kilo ohms
ge=((rx-rt)/rx)*100;#percentage gross error
print"percentage gross error is",round(ge,2)
print"when current reading is 50mA"
vr=100.;#voltmeter reading
ir1=50.;#mA
rt1=vr/(ir1);#in kilo ohms
print"apparent resistance in kilo ohms is",rt1
vm=150.;#range of voltmeter
s=1;#kilo ohms per volts sensivity
rv=s*vm;#kilo ohms
rx1=((rt1*rv)/(rv-rt1));#kilo ohms
ge1=((rx1-rt1)/rx1)*100;#percentage gross error
print"percentage gross error is",round(ge1,2)
#Example 1.3:#limiting error
#calculate the limiting error
#given
fs=1.5;#full scale in percentage
vr=500.;#voltmeter reading
#calculations
ea=(fs/100)*vr;#volts
le=150;#limiting error voltage
lep=((ea/le)*100);#limiting error
#results
print "limiting error at 150 V is (%)=",lep
#Example 1.4:#ARITHMETIC MEAN,AVERAGE DEVIATION ,STANDARD DEVIATION AND PROBABLE ERROR
#calculate the ARITHMETIC MEAN,AVERAGE DEVIATION ,STANDARD DEVIATION AND PROBABLE ERROR
#given
import math,numpy
T=numpy.array([99.7,99.8,100,100.2,100.3]);#VOLTS
q=numpy.array([T[0],T[1],T[2],T[3],T[4]]);#
#calculations
AM=(q[0]+q[1]+q[2]+q[3]+q[4])/5;#arithematic mean in mm
qb=numpy.zeros(6)
for i in range(0,5):
qb[i]= T[i]-AM;
Q= numpy.array([qb[0],qb[1],qb[2],qb[3],qb[4]]);#
AV=(-qb[0]-qb[1]-qb[2]+qb[3]+qb[4])/5;#
SD=math.sqrt(((qb[0]**2)+(qb[1]**2)+(qb[2]**2)+(qb[3]**2)+(qb[4]**2))/5);#standard deviation
V=SD**2;#
#results
print"arithmetic mean is, (V)=",AM
print"average deviation is, (V)=",AV
print"standard deviation is, (V)=",round(SD,3)
print"Variance is ,(V)=",V
#Example 1.5:#error
#calculate the error in power
#given
i=8.2;#in amperes
r=20.;#ohms
nd=100.;#divisions
ra=10.;#range in amperes
d=0.5;#divisions
amcr=1.;#ammemeter constant error
crr=-0.2;#construction error
#calculations
p=i**2*r;#watts
rd1=ra/nd;#reading of one division
per=((d*rd1)/i)*100;#possible ameter rwading error
ter=amcr+per;#total ammeter error
ep=(((2*ter)+crr)/nd)*p;#
#results
print "power is,(W)=",p
print "error in power is,(W)=",round(ep,3)
#Example 1.6:#ARITHMETIC MEAN
#calculate the arithmetic mean
#given
import numpy
T=numpy.array([99.7,99.8,99.9,100,100.1,100.2,100.3]);#VOLTS
f=numpy.array([2,8,20,40,21,6,3]);#frequency of occurence
#calculations
qb=numpy.zeros(8)
for i in range (0,7):
qb[i]=T[i]-T[5];
prdtc=(qb[0]*f[0])+(qb[1]*f[1])+(qb[2]*f[2])+(qb[3]*f[3])+(qb[4]*f[4])+(qb[5]*f[5])+(qb[6]*f[6])
am=T[5]+(prdtc/100);#arithemetic mean
#results
print "arithmetic mean is (V)=",am
#Example 1.7:#limiting error
#calculate the limiting error for power
#given
fse=1.;#full scale deflection
vr=150.;#range in volts
v1=100.;#volts
ve=100.;#range in mA
#calculations
ev=(fse/100)*vr;#voltas
le100=((ev)/v1)*100;#in percentage
ee=(fse/100)*ve;#mA
e1=55;#mA
le50=((ee/e1)*100);#in percentage
ler=le100+le50;#
#results
print "limiting error for power is, (%)=",round(ler,1)
#pg 37
#Example 1.8:# error
#calculate the volume, percentage error
#given
fse=1.;#full scale deflection
e=0.60;#meters
#calculations
v=(e)**3;#volume in m^3
ev=3*fse;#error in volume
evv=(ev/100)*v;#
#results
print "volume is,(m^3)=",v
print "percentage error in volume is,(%)=",ev
print "error in volume is,(m^3)=",evv
#Example 1.9:#error
#calculate the error in circuit
#given
v=95.;#volts
r=40.;#ohms
evv=0.95;#error in voltage
err=-0.2;#error in resistance
#calculations
i=v/r;#amperes
err1=(err/r)*100;#percentage error
evv1=(evv/v)*100;#percentage error
x=evv1-err1;#
ei=(x/100)*i;#
#results
print "current in the circuit is,(A)=",i
print "error in current is,(A)=",round(ei,4)
print "percentage error in current is,(%)=",x
#Example 1.10:#MAGNITUDE AND LIMITING ERROR
#calculate the magnitude of resistance and limiting error
#given
print "parralel resistance case"
r1=40.;#ohms
er1=5.;#percentage error
r2=80.;#ohms
er2=5.;#percentage error
r3=50.;#ohms
er3=5.;#percentage error
#calculations
rp=((r1*r2*r3)/(r1*r2+r2*r3+r3*r1));#ohms
Y=(r1*r2+r2*r3+r3*r1);#ohms
ex=er1+er2+er3;#percentage error
ey1=er1+er2;#
ey2=er2+er3;#
ey3=er3+er1;#
y=(((r1*r2*ey1)/Y)+((r2*r3*ey2)/Y)+((r3*r1*ey3)/Y));#error
mer=(y+ex)*rp;#
#results
print "magnitude of resistance in ohms is = ",round(rp,3)
print "limiting error in ohms is = ",round(mer/100,3)
print "percentage error (%) = ",(y+ex)
print "series resistance case"
rs=r1+r2+r3;#ohms
er=(((r1/rs)*er1)+((r2/rs)*er2)+((r3/rs)*er3));#
mer1=(er/100)*rs;#ohms
print "magnitude of resistance in ohms is = ",rs
print "percentage error (%) = ",er
print "limiting error in ohms is = ",mer1
#Example 1.11:#MAGNITUDE AND LIMITING ERROR
#calculate the magintude of resistance in ohm and error
#given
r1=50;#ohms
er1=0.5;#percentage error
r2=100;#ohms
er2=0.5;#percentage error
r3=75.5;#ohms
er3=0.5;#percentage error
#calculations
x=((r2/r1)*r3);#ohms
eps=er1+er2;#
erpsq=eps-er3;#when error in both (PS) and (Q) is positive
erpsq1=eps+er3;#when error in (PS) is positive and (Q) is negetive
oer1=(erpsq/100)*x;#ohms
oer2=(erpsq1/100)*x;#ohms
#results
print "magnitude in ohm = ",x
print "percentage error when error in both (PS) and (Q) is positive (%) = ",erpsq
print "error in ohms when error in both (PS) and (Q) is positive (ohms) = ",oer1
print "percentage error when error in (PS) is positive and (Q) is negative (%) = ",erpsq1
print "error in ohms when error in (PS) is positive and (Q) is negative (ohms) = ",oer2