# Chapter 12 : Behaviour of analog systems in the presence of noise¶

## page no 536 Example 12.1¶

In :
from math import pi,log
#from mpmath import quad
from mpmath import quad
# Let the received signal be km(t)cos(wct) , demodulator input is [km(t)+nc(t)]cos(wct)+[ns(t)sin(wct)]. When this is multiplied by 2coswct and low pass filtered the output is s0(t)+n0(t)=km(t)+nc(t).
# Hence So=k**2*m**2' , No=nc**2'. But the power of the received signal km(t)cos(wct)= 1uW. Hence k**2*m**2'/2=10**-6
So=2*10**-6#
# to compute nc: (nc**2)'=(n**2)'=x
t0=496000.#
t1=504000. #
a=10**6 * pi#
y=quad (lambda t:1/((t**2)+(a**2)),[t0,t1])
# to compute output SNR
SNR=So/y#
val=(10.*(log (SNR)))#
print "output SNR = %0.2f dB"%val

output SNR = 78.36 dB


## Page 540 Problem 12.2¶

In :
from math import log,exp
#as En=sqrt(nc**2+ns**2),where both nc and ns are gaussian with variance 6n**2,according to the following eqn P(En>=A)=integrate(En/6n**2)*e**(-En**2/2*6n**2)dEn#
# the value of this integral is the probability of which is 0.01
#hence e**(-A**2/2*6n**2)=0.01
#let g=A**2/(2*6n**2)#
g=-(log(0.01)/log(exp(1)))#
# the variance 6n**2 of the bandpass noise of PSD N/2 and the bandwidth 2B is 2NB.Hence at the onset of the threshold
# therefore A**2/(2*6n**2)=A**2/(4NB)=g
#for tone modulation
#Si=A**2+m'**2/2#
#Si=3*A**2/4#
gma_th=3*(g)## gma_th=Si/NB=3*A**2/(4NB)#
print 'gamma threshold : %0.4f'%gma_th

gamma threshold : 13.8155


## Page 547 Problem 12.3¶

In :
# for a gaussian m(t),mp will be assumed as 36m
Sg=3##assumed
Mbar=(Sg**2)#
MP=((3.*Sg)**2)#
B=0.2##ASSUMED
gma=0.4##assumed
SNR=3.*B**2*(Mbar/MP)*gma#
print 'SIGNAL TO NOISE RATIO : %0.4f'%SNR

SIGNAL TO NOISE RATIO : 0.0053


## Page 550 Problem 12.4¶

In :
from mpmath import quad
t0=-5#
t1=5#
y=quad(lambda t:t**2,[t0,t1])#
f=quad(lambda t:1,[t0,t1])
Bm=y/f#
print 'value of Bm : %0.4f'%Bm

value of Bm : 8.3333


## Page 550 Problem 12.5¶

In :
from mpmath import quad
from math import exp
# Sm(w)=k*e**(-w2/26**2) this is given
# let us the assume the value of constant 6**2/4(pi**2) =3
# thus the variance can be calculated as
f0=0#
f1=15#
y=quad(lambda f:(f**2)*(exp(-(f**2)/6)),[f0,f1])
g=quad(lambda f:exp(-(f**2)/6),[f0,f1])#
v=y/g#
print 'Bm2 : ',v

Bm2 :  3.0


## Page 552 Prob 12.6¶

In :
from mpmath import quad
from math import exp,pi
#for the same transmission bandwidth variance of PM and FM systems is same
#hence the ratio of SNR of PM to FM is B**2/(3Bm'**2)
#assuming 6=1
B=3/(2*pi)##because W=2*pi*B
#variance is Bm2
f0=0#
f1=15.#
y=quad(lambda f:(f**2)*(exp(-(f**2)*2*(pi**2))),[f0,f1])
g=quad(lambda f:exp(-(f**2)*2*(pi**2)),[f0,f1])
Bm2=y/g#
l=(B**2)/(3*(Bm2))#
print 'factor of superiority of PM over FM : ',l

factor of superiority of PM over FM :  3.0


## page no 555 Example 12.7¶

In :
from math  import log
B=4# SNR=20.5# # given
r=20*(B+1)##as B=4
#output SNR is given as So/No=3*B**2*r*(m**2'/mp**2)
m=4.# m=mp/6m is given
SNRt=3*(B**2)*r*(1/m)**2#
print "threshold SNR = %0.2f "%SNRt
# to calculate output SNR in dB
SNRdB=20*log(SNR)#
print "Threshold SNR = %0.2f dB "%SNRdB
if 20.5<SNRdB:
print "system is in threshold"
else:
print 'system is not in threshold'

threshold SNR = 300.00
Threshold SNR = -104.68 dB
system is not in threshold


## Page 561 Prob 12.8¶

In :
from math import log10
#for a gausssian signal,mp=infinity(00),but we may assume 36 loading,thus mp=3*6,
Sgm=3.#
m2=(Sgm**2)#
mp2=((3*Sgm)**2)#
y=(m2)/(mp2)#
# to calculate SNR,we have SNR=3(2**n)*((m**2)/(mp**2))
n=8##given
l=3*(2**(2*n))*y##by formula
print 'SNR is equal : %0.2f'%l
print 'SNR = %0.3f dB'%(10*(log10(l)))

SNR is equal : 21845.33
SNR = 43.394 dB


## Page 567 Prob 12.10¶

In :
from math import pi,sqrt,exp
from mpmath import quad
# to calculate |m|
m0=0#
m1=50.#
m=quad(lambda m:(m*(exp(-(m**2)/2.))),[m0,m1])##assuming 6m=1
print 'value of |m| : %0.2f'%(sqrt(2/pi)*m)

value of |m| : 0.80


## Page 569 Prob 12.11¶

In :
from math import pi,sqrt
from mpmath import quad
a=1400.*pi##given
c=1.##assumed
w0=0
w1=8000.*pi#
S=quad(lambda w:1/((w**2)+(a**2)),[w0,w1])
So=S/pi#
print 'transmitted power : %0.2e'%So##assuming G=1,hence St=So
#assuming N=1
No=4000.##because No=N*B
SNR=So/No#
print 'SNR without pre-emphasis and de-emphasis : %0.2e'%SNR
S=quad(lambda w:1/(sqrt((w**2)+(a**2))),[w0,w1])#
print 'S is %0.2e'%S
SNRo=(10**-8)*4*(pi**2)/(2*(S**2))#
print 'SNR at the output : %0.2e'%SNRo
print 'Improvement factor in SNR with pre-emphasis and de-emphasis : %0.2f'%(SNRo/SNR)

transmitted power : 1.01e-04
SNR without pre-emphasis and de-emphasis : 2.53e-08
S is 2.44e+00
SNR at the output : 3.31e-08
Improvement factor in SNR with pre-emphasis and de-emphasis : 1.31