Chapter12 Digital Communications

Example 12.4.1,Pg.no.419

In [47]:
import math
from math import sqrt,erf,erfc
Vs_Vn=4   #SNVR 
a=erf(4/sqrt(2))
b=erfc(4/sqrt(2))*10**5
Pbe=(0.5)*(b)  #bit error probability
a=round(a,2)
b=round(b,2)
print 'a=',a
print 'b=',b,'*10**-5'
Pbe=round(Pbe,2)
print 'The bit error probability',Pbe,'*10**-5'
a= 1.0
b= 6.33 *10**-5
The bit error probability 3.17 *10**-5

Example 12.4.2,Pg.no.420

In [43]:
import math
A=4     #max value of received signal voltage
Vn=0.5  #rms noise voltage
Vth=2   #Threshold voltage for the comparator
b=erfc(Vn/sqrt(2))
Pbe=(0.5) * b  #bit error probability
Pbe=round(Pbe,3)
print 'The bit error probability',Pbe 
The bit error probability 0.309

Example 12.4.3,Pg.no.421

In [41]:
import math
from math import erfc
SNR=9.0   #SNR in dB
#conversion of dB to power ratio
p=10**(9/10)  #for Polar
Pbe1=0.5*erfc(sqrt(7.94/2))
Pbe1=round(Pbe1,4)
print 'Bit Probabilty,Pbe1=',Pbe1
#for Unipolar
Pbe2=0.5* erfc(sqrt(7.94)/2)
Pbe2=round(Pbe2,4)
print 'Bit Probability,Pbe2=',Pbe2
Bit Probabilty,Pbe1= 0.0024
Bit Probability,Pbe2= 0.0232

Example 12.5.1,Pg.no.423

In [37]:
import math
Pavg=6.0*10**-12    #in W
d=0.02*10**-6     #pulse duration in sec
T=550.0           #equivalent noise temp in K
Eb=Pavg*d         #avg energy per pulse
No=1.38*10**-23*T
r=Eb/No           #Bit error probability is
Pbe=0.5*erfc(sqrt(r/2))*10**5
Pbe=round(Pbe,1)
print 'The bit error probability',Pbe,'*10**-5' 
The bit error probability 3.5 *10**-5

Example 12.9.1,Pg.no.435

In [33]:
import math
from math import exp
ENR=10.0   #energy to noise density ratio
Pbe1=0.5* erfc(sqrt(ENR/2))
Pbe1=round(Pbe1,5)
print 'a)The bit error probability',Pbe1
Pbe2=(0.5)*exp(-(ENR/2))
Pbe2=round(Pbe2,5)
print 'b)The bit error probability',Pbe2
a)The bit error probability 0.00078
b)The bit error probability 0.00337

Example 12.13.1,Pg.no.451

In [24]:
import math
Pbec=0.01
n=8.0
i=3.0
Pi=(Pbec**i)*((1-(Pbec))**(n-i))
Cin=(math.factorial(n))/(math.factorial(i)*math.factorial(n-i))
Pin=Cin*Pi*10**5
P_in=Cin*Pbec**i*10**5
Pin=round(Pin,2)
P_in=round(P_in,2)
print 'The probability of a received codeword',Pin,'*10**5'
print 'P_in=',P_in,'*10**5'
The probability of a received codeword 5.33 *10**5
P_in= 5.6 *10**5

Example 12.13.3,Pg.no.454

In [22]:
import math
from math import sqrt,erf
SN_dB=9
SNR=10**(SN_dB/10)
PbeU=0.5 * (1-erf(sqrt(SNR)))
BERu=PbeU
BERu=round(BERu,3)
print 'a)The bit error probability',BERu
n=10
k=n-1
r=k/n
SNR1=r*SNR
PbeC=0.5 *(1-erf(sqrt(SNR1)))
BERc=(n-1)*PbeC**2
print 'b)The bit error probability',BERc
a)The bit error probability 0.079
b)The bit error probability 2.25

Example 12.13.4,Pg.no.457

In [20]:
import math
from math import sqrt
SN_dB=8
SNR=10**(SN_dB/10) #a) Determination of bit error rate
PbeU=0.5*(1-erf(sqrt(SNR)))
BER_U=PbeU
BER_U=round(BER_U,3)
print 'a)The bit−error rate is',BER_U
#b)new bit error rate
n=15
k=11
t=1
r=k/n
SNR_n=r*SNR
PbeC=0.5*(1-erf(sqrt(SNR_n)))
BER_C=((math.factorial(n-1))*PbeC**(t+1))/((math.factorial(t)) *(math.factorial(n-t-1)))
print 'b)The new bit error rate is',BER_C 
a)The bit−error rate is 0.079
b)The new bit error rate is 3.5