# Page Number: 10.18
# Example 10.1
from math import sqrt,erfc
# Given
Rb=1.*10.**6.; # b/s
A=5.*10.**3.; # V
N0=0.5*10.**11.; # W/Hz
Tb=1./Rb;
Eb=(A*A*Tb)/2.;
# (a) ASK
# Pe=Q(x)
# where
xA=sqrt(Eb/N0);
PeA=(1./2.)*erfc(xA/1.414);
print'For ASK:',round(PeA,2)
# (b) PSK
# Pe=Q(x)
# where
xP=sqrt((2.*Eb)/N0);
PeP=(1./2.)*erfc(xP/1.414);
print'For PSK:',round(PeP,2)
# (c) FSK
# Pe=Q(x)
# where
xF=sqrt(Eb/N0);
PeF=(1./2.)*erfc(xF/1.414);
print'For FSK:',round(PeF,2)
# Page Number: 10.19
# Example 10.2
from math import sqrt,erfc
# Given
Rb=1.*10.**6.; # b/s
# (a)
Aa=1.*10.**3.; # V
N0=1*10.**11.; # W/Hz
Tb=1./Rb;
Eba=(Aa*Aa*Tb)/2.;
# Pe=Q(z)
# where
za=sqrt((2.*Eba)/N0);
Peb=(1./2.)*erfc(za/1.414);
print'For Average bit error probability:',round(Peb,5)
# (b) Maintain Pb=2*10**3
# From table
zb=2.9;
Ebb=((zb**2.)*N0)/2.;
P=Ebb*Tb;
Ab=sqrt((2.*P));
print'Average Power:',round(Ab,2),'V'
# (c)
Ac=100.; # V
Rbc=1.*10.**5.; # p/s
N01=1.*10.**2.; # W/Hz
Tbc=1./Rbc;
Ebc=(Ac*Ac*Tbc);
zc=sqrt(((2.*Ebc)/N01));
Pec=(1./2.)*erfc(zc/1.414);
# Pec=0.0000039
# nearly 10**-5
print'For Average bit error probability for bipolar antipodal signals:',10**-5
# Page Number: 10.23
# Example 10.6
# Given
import math
p=0.1; # dB
p1=10.**(-p/10.);
p2=math.sqrt(p1);
t=8.68;#math.acosd(p2);
a=round(t);
print'System cannot tolerate more than:',a,'degrees'
# Page Number: 10.28
# Example 10.11
from math import sqrt,erfc
# Given
Rb=1.*10.**6.; # b/s
T=1.*10.**5.;
N0=2.*0.5*10.**7.; # W/Hz
# From table for Q(z)=10**-5
z=4.25;
# As z=sqrt(A*A*T/2*N0)
x=((z**2.)*2.*N0)/T;
A=sqrt(x);
print'Required value of A:',round(A,2)
# (b) Bandwidth
# B=1/(2*(T/2))
# Therefore B=1/T
B=(1./T);
print'Bandwidth:',round(B,2),'Hz'
# Page Number: 10.33
# Example 10.17
from math import sqrt,erfc
# Given
A=0.2*10.**3.; # V
T=2.*10.**6.; # s
n=2.*1.*10.**15.; # W/Hz
# Pe=Q(z)
# where
x=(A*A*T)/(4.*n);
z=sqrt(x);
Pe=(1./2.)*erfc(z/1.414);
print'Error probability:',round(Pe,2)
# Page Number: 10.34
# Example 10.18
from math import sqrt,erfc
# Given
A=0.2*10.**3.; # V
A1=A/1.414;
T=2.*10.**6.; # s
n=2.*1.*10.**15.; # W/Hz
# Pe=Q(z)
# where
x=(A1*A1*T)/(n);
z=sqrt(x);
Pe=(1./2.)*erfc(z/1.414);
print'Error probability:',round(Pe,2)
# Page Number: 10.35
# Example 10.19
from math import sqrt,erfc
# Given
d12sqr=8.;
N0=2.*0.5; # W/Hz
# (c)
# As for two equiprobables
# Pe=Q(z)
# where z=sqrt(d12**2)/sqrt(2*N0)
z=sqrt((d12sqr)/(2.*N0));
Pe=(1./2.)*erfc(z/1.414);
print'Probabilty error:',round(Pe,2)
# Page Number: 10.36
# Example 10.20
from math import sqrt,erfc
# Given
c=sqrt(2.);
A=sqrt(5.);
N0=1.; # W/Hz
d12sqr=4.*A*A;
# As for two equiprobables
# Pe=Q(z)
# where z=sqrt(d12**2)/(2*N0)
z=sqrt((d12sqr)/(sqrt(2.*N0)));
Pe=(1./2.)*erfc(z/1.414);
print'Probabilty error:',round(Pe,4)
# Page Number: 10.41
# Example 10.24
# (a) Number of constellation Points
# Given
Rs=2400.; # bps
Rb=19.2*10.**3.; # bps
# As Rs=Rb/log2M
M=2.**(Rb/Rs);
print'Number of constellation points =',round(M,2)
# (b) Bandwidth efficiency
BT=2400; # Symbols/second
n=Rb/BT;
print'Bandwidth efficiency = ',round(n,2),'bps/hz'
# Page Number: 10.41
# Example 10.25
from math import sqrt,erfc
# Given
A1=0.5;
A2=0.5;
T=0.01; # sec
N0=2.*0.0001; # W/Hz
f=50.; # Hz
# (a) Probability of bit error
Es1=(A1**2.*T)/2.;
Es2=(A2**2.*T)/2.;
Eb=(Es1+Es2)/2.;
# As PE=Qsqrt(Ep+Eq-2Epq/2N0)
# In this case Ep=Eq=Eb
# Therefore PE=Qsqrt(Eb(1-p)/N0)
# where p=Epq/Eb
# p=(1/Eb)*integrate('0.5*cos(2000*%pi*t)*0.5*cos(2020*%pi*t)','t',0,T);
# We get
p=0.94;
q=1.-p;
# As Pe=Q(z)
# where z=sqrt(Eb/N0)
z=sqrt((Eb*q)/N0);
Pe=(1./2.)*erfc(z/1.414);
print'Probabilty of bit error :',round(Pe,2)
# (b)
# Given
fs=50.; # Hz
# or fs=1/2T where T=0.001
# This implies y=tone spacing will be orthogonal
# Therefor p=0
# As Pe=Q(z)
# where z=sqrt(Eb/N0)
zb=sqrt(Eb/N0);
PB=(1./2.)*erfc(zb/1.414);
print'Probabilty error for fs=50Hz :',round(PB,2)
# Page Number: 10.43
# Example 10.27
# Given
Rb=4.8*10.**3.; # b/s
bw=3.2*10.**3.; # Hz
# BPSK can give maximum spectral efficiency of 1bps/Hz, therefore not suitable
# QPSK can give twice spectral efficiency,2bps/Hz, therefore
qpsk=2.*bw;
# PSK can give thrice spectral efficiency,3bps/Hz, therefore
psk=3.*bw;
# QPSK is most suitable
Rs=Rb/2.;
# Roll off Factor
a=(bw/Rs)-1.;
ap=a*100.;
print'Roll off factor:',ap,'%'