# Chpater 3: WAVEFORM CODING TECHNIQUES

## Example 3,1 Page No 110¶

In [104]:
print('This is a Theoretical  example')

This is a theoretcal example


## Example 3,2,i, Page No 111¶

In [105]:
import math
#find code word length

#Variable Declaration
#Given data
bandwidth=4.2*10**6
fm=bandwidth
q=512        #Quantization levels
#q=2^v

#Calculation
v=math.log10(512)/math.log10(2)

#Result
print("The code word legth is = %.f bits" %v)

The code word legth is = 9 bits


## Example 3.2.ii, Page No 111¶

In [106]:
import math

#find The transmission Bandwidth

#Variable Declaration
#Given data
bandwidth=4.2*10**6
fm=bandwidth
q=512.0           #Quantization levels
v=9.0

#Calculation
bw=v*fm*10**-6

#Result
print("The transmission Bandwidth is = %.1f MHz" %bw)

The transmission Bandwidth is = 37.8 MHz


## Example 3.2.iii, Page No 111¶

In [107]:
import math
#find  Final Bit rate

#Variable Declaration
#Given data
bandwidth=4.2*10**6
fm=bandwidth
q=512.0      #Quantization levels
v=9.0

#Calculation
fs=2*fm
r=v*fs       #signaling rate

#Result
print("Final Bit rate =%.1f x 10^6 bits/sec" %(r/(10**6)))

Final Bit rate =75.6 x 10^6 bits/sec


## Example 3.2.iv, Page No 111¶

In [108]:
import math
#find Output signal to noise ratio

#Variable Declaration
#Given data
bandwidth=4.2*10**6
fm=bandwidth
q=512         #Quantization levels
v=9.0

#Calculation
sn=4.8+6*v    #noise in dB

print("Output signal to noise ratio is = %.1f dB" %sn)

Output signal to noise ratio is = 58.8 dB


## Example 3.3.i, Page No 112¶

In [109]:
import math
#find bits per sample

#Variable Declaration
fmax=4*10**3
xmax=3.8
snr=100

#Calculation
P=30*10**-3
v=(math.log10(((snr*xmax**2)/(3*P)))/(2*math.log10(2)))

#Result
print("Number of bits required per sample are = %.2f bits" %v)

Number of bits required per sample are = 6.98 bits


## Example 3.3.ii, Page No 168¶

In [110]:
import math

#Find  Transmission Bandwith

#Variable Declaration
#Given data
fm=4*10**3     #Bandwidth of PCM
xmax=3.8
snr=100       #Signal to Noise Ratio
outputs=30.0
v=7.0

#Calculation
bw=outputs*v*fm
r=bw*2
bw=bw/10**3

#Result
print('Transmission Bandwith R = %.f kHz' %bw)
r=r/1000
print('Signaling rate R = %.f bits/sec' %r)

Transmission Bandwith R = 840 kHz
Signaling rate R = 1680 bits/sec


## Example 3.4, Page No 112¶

In [111]:
import math

#find sampling rate,number of bits,bit rate,bandwidht

#Variable Declaration
#Given data
emax=0.001
de=2*emax
fm=100.0
xmax=10.0

#Calculation
q=(2*xmax)/de
fs=2*fm
v=(math.log10(q))/math.log10(2)
v=math.ceil(v)
r=v*fs

#Result
print('1. sampling Frequncy  =  %.f  Hz ' %fs)
print('2. No.of bits in PCM  =  %.f  bits ' %v)
print('3. sampling rate  =  %.f  bits per second ' %r)
r=r/2
print('4. Transmission Bandwidth  =  %.f  Hz ' %r)

1. sampling Frequncy  =  200  Hz
2. No.of bits in PCM  =  14  bits
3. sampling rate  =  2800  bits per second
4. Transmission Bandwidth  =  1400  Hz


## Example 3.5, Page No 113¶

In [112]:
import math
#Find  Bandwidth,Sampling Rate

#Variable Declaration
#Given data
fm=3.4*10**3
N=24
r=1.5*10**6
encoder=8

#Calculation
BW=N*fm
BW=BW/10**3
r1=r/N
fs=r1/encoder

#Result
print("i. Channel Bandwith is = %.2f kHz" %BW)
print("ii. Sampling frequency is = %.2f Hz or samples per second." %fs)

i. Channel Bandwith is = 81.60 kHz
ii. Sampling frequency is = 7812.50 Hz or samples per second.


## Example 3.6, Page No 114¶

In [113]:
import math

#Find Signal Bandwidth,Noise Ratio

#Variable Declaration
#Given data
v=7
r=50*10**6

#Calculation
#fs=2*fm
fm=r/(2*v)
snr=1.8+(6*v);
fm=fm*10**-6

#Result
print('i. Maximum message Bandwidth is = %.2f MHz ' %fm)
print('ii.  signal to quantization niose ration = %.2f dB ' %snr)

i. Maximum message Bandwidth is = 3.57 MHz
ii.  signal to quantization niose ration = 43.80 dB


## Example 3.7, Page No 114¶

In [114]:
import math

#find i)bits per sample,ii)transmission rate

#Variable Declaration
#Given data
fm=3*10**3
q=16

#Calculation
v=(math.log10(q))/math.log10(2)

#Result
print('i) Bits in code word= %.f bits' %v)
fs=2*fm
r=v*fs
print('ii) it trasmission rate= %.f x 10^3 bits per second' %(r/(10**3)))

i) Bits in code word= 4 bits
ii) it trasmission rate= 24 x 10^3 bits per second


## Example 3.8, Page No 115¶

In [115]:
import math

#Find signal to noise ratio

#Variable Declaration
#Given data
fm=3.5*10**3
r=50*10**3

#Calculation
fs=2*fm
rms=0.2
xmax=2
v=r/fs    #signaling rate r=v*fs
v=math.ceil(v)
P=(rms**2)/1
SNR=((3*P*2**(2*v))/(xmax**2))
SN=10*math.log10(SNR)
SN=math.ceil(SN)

#Result
print("signal to niose ratio =%.f dB" %SN)

signal to niose ratio =33 dB


## Example 3.10, Page No 117¶

In [116]:
import math
#Find i)noise ratio ii)bits

#Variable Declaration
#Given data
Am=3.0
v=10.0

#Calculation
SNR=1.8+6*v     #noise ratio
SN=40
v=(SN-1.8)/6

#Result
print("i) Signal to Quantization noise ratio = %.1f dB" %SNR)
print("ii) Bits required to get signal to niose ratio of 40dB = %.f " %math.ceil(v))

i) Signal to Quantization noise ratio = 61.8 dB
ii) Bits required to get signal to niose ratio of 40dB = 7


## Example 3.11, Page No 117¶

In [117]:
import math
#Find Maximum frequency

#Variable Declaration
#Given data
v=7
SNR=1.8+6*v
r=56*10**3

#Calculation
fs=r/v        #r=v*fs signaling rate
fm=fs/2       #Nquset rate

#Result
fm=fm/10**3
print("Maximum frequency is = %.f kHz" %fm)

Maximum frequency is = 4 kHz


## Example 3.14, Page No 129¶

In [118]:
import math
#Find  Maximum Amplitude

#Variable Declaration
fm=3*10**3.0

#Calculation
Nyquistrate=2*fm     #Nyquistrate
fs=5*Nyquistrate     #Samplingfrquency
Ts=1/fs              #Sampling Interval
de=0.25             #step size
fm1=2*10**3.0
Am=de/(2*math.pi*fm1*Ts)

#Result
print("Maximum Amplitude = %.4f Volts" %Am)

Maximum Amplitude = 0.5968 Volts


## Example 3.16, Page No 130¶

In [119]:
import math
#Find  signaling rate

#Variable Declaration
fs1=8*10**3.0
de=31.25*10**-3
q=64.0

#Calculation
v=math.log(q,2)
r=v*fs1            #signaling rate
fm=3*10**3.0
A=1
fs2=(2*math.pi*fm*A)/(de)

#Result
r=r*10**-3
print("Signaling rate of PCM is = %.f kHz" %r)
fs2=fs2*10**-3
print("The signaling rate of DM is = %.2f kHz" %fs2)

Signaling rate of PCM is = 48 kHz
The signaling rate of DM is = 603.19 kHz


## Example 3.17, Page No 131¶

In [120]:
import math
#Find  signal to noise ratio

#Variable Declaration
fs=64.0*10**3     #frequency
fm=2.0*10**3      #Sinosoidal input signal sample
fM=4.0*10**3      #bandwidth

#Calculation
SNR=(3*fs**3)/(8*math.pi**2*fm**2*fM)   #Signal to noise ratio
SNRO=10*math.log10(SNR)

#Result
print("Output signal to noise ratio = %.2f dB" %SNRO)

Output signal to noise ratio = 27.94 dB


## Example 3.18, Page No 131¶

In [121]:
import math
#Find  signal to Quatization noise ratio

#Variable Declaration
fs=8.0*10**3        #Sampling frequency
r=64.0*10**3        #Data Rate
N=8        #number of bits

#Calculation
SNR=(1.8+6*N)     #signal to Quatization noise ratio

#Result
print("Signal to Quatization noise ratio of PCM system is = %.f dB" %SNR)

Signal to Quatization noise ratio of PCM system is = 50 dB


## Example 3.20, Page No 149¶

In [122]:
import math

#Find  sampling rate,quantizing level

#Variable Declaration
r=36000
fm=3.2*10**3

#Calculation
fs=2*fm        #Nquest rate
v=r/fs         #r=v*fs signaling rate
v=math.floor(v)
q=2**v
fs1=r/v

#Result
print("Quantizing level q = %.f " %q)
fs1=fs1/1000
print("sampling rate fs = %.1f kHz " %fs1)
print("Number of binary digits = %.f  " %v)

Quantizing level q = 32
sampling rate fs = 7.2 kHz
Number of binary digits = 5


## Example 3.21, Page No 149¶

In [123]:
import math
#Find  time duration of 1bit  binary encoded signal

#Variable Declaration
fs=input("Enter the Nyquist rate of Signal fs(Hz)=")
q=input("Enter the Quantization levels q =")

#Calculation
v=math.log(q,2)     #binary pulses transmitted per second
t=1.0/(v*fs)        #Nyquist interval

#Result
print('Time duration of binary signal  t = %.4f sec ' %t)
#output
#Enter the Nyquist rate fs(Hz)=3
#Enter the Quantization levels q =5
#time duration of 1bit binary signal
#t=0.1435589  sec

Enter the Nyquist rate of Signal fs(Hz)=23
Enter the Quantization levels q =34
Time duration of binary signal  t = 0.0085 sec


## Example 3.23, Page No 150¶

In [124]:
import math
#find signal to noise ratio

#Variable Declaration
SNR=40
SNRO=10**(SNR/10)

#SNR=3(q**2)/2, Signal to Quantization noise ratio

#Calculation
q=math.sqrt((2*SNRO)/3)
q=math.ceil(q)
v=math.log(q,2)         #q=2**v  Quantization levels
v=math.ceil(v)
snr=1.76+6.02*v          #output Signal to Quantization noise ratio

#Result
print("Output Signal to Quantization noise ratio = %.1f dB" %snr)

Output Signal to Quantization noise ratio = 43.9 dB


## Example 3.24.i, Page No 150¶

In [125]:
import math
#Find  Quantizing  levels,minimum number of bits per sample

#Variable Declaration
SNRO=30.0
fmin=300.0
fmax=3300.0
fs=80000.0

#Calculation
#SNRO=1.76+20log10(q)
q=10**((SNRO-1.76)/20)
q=math.ceil(q)
v=math.log(q,2)

#Result
print('Quantizing  levels required is =%.f' %q)
print('minimum number of bits per sample are=%.1f that is approximately 5' %v)

Quantizing  levels required is =26
minimum number of bits per sample are=4.7 that is approximately 5


## Example 3.24.ii, Page No 150¶

In [126]:
import math
#Find  minimum required bandwidth

#Variable Declaration
SNRO=30.0       #Signal to quantisizing noise ratio
fmin=300.0      #min frequency band
fmax=3300.0     #max frequency band
fs=8000.0       #Sampling rate
v=5.0           #Minimum number of bits per sample

#Calculation
fPCM=(v*fs)/2
fPCM=fPCM/1000

#Result
print('minimum required bandwidth =%.f kHz' %fPCM)

minimum required bandwidth =20 kHz


## Example 3.24.iii, Page No 150¶

In [127]:
import math
#Find  Quantizing  levels,minimum number of bits per sample and bandwidth

#Variable Declaration
SNRO=30.0       #Signal to quantisizing noise ratio
fmin=300.0      #min frequency band
fmax=3300.0     #max frequency band
fs=8000.0       #Sampling rate

#Calculation
q=10**((SNRO+10.1)/20)
q=math.ceil(q)
v=math.log(q,2)
v=math.ceil(v)

#Result
print('Quantizing  levels need is =%.f' %q)
print('minimum number of bits per sample is =%.f' %v)
fPCM=(v*fs)/2
fPCM=fPCM/1000
print('minimum required bandwidth =%.f Khz' %fPCM)

Quantizing  levels need is =102
minimum number of bits per sample is =7
minimum required bandwidth =28 Khz


## Example 3.27, Page No 152¶

In [128]:
import math

#determine the  Maximum Amplitude,

#Variable Declaration
de=250*10**-3
wm=2*math.pi*1000
fs=3*10**3
Ts=1/fs

#Calculation
Amax=(de*3*fs*2)/(wm) #Amplitude
SNR=(3.0*((3*6*(10**3))**3))/((8*(math.pi**2)*(10**3)**3))

#Result
print('Maximum Amplitude= %.1f mV' %(Amax*(10**2)))
print('Signal to noise ratio = %.2f dB' %(10*math.log10(SNR)))

Maximum Amplitude= 71.6 mV
Signal to noise ratio = 23.46 dB


## Example 3.29, Page No 153¶

In [129]:
import math
#Find number of bits per sample

#Variable Declaration
SNR=20
averagepower=30*10**-3
SNRO=10**(SNR/10)
A=3.8

#SNRO=average signal power/Quatizing power
#de=(2*A)/L

#Calculation
L=math.sqrt((SNRO*A**2)/(3*averagepower))
n=math.log(L,2)
n=math.ceil(n)

#Result
print('Bits required per sample =%.f' %n)

Bits required per sample =7


## Example 3.30.i, Page No 153¶

In [130]:
import math
#Find  Normalized power for quantization noise

#Variable Declaration
fm=3.0*10.0**3
v=8.0
VH=5.0
VL=-5.0
q=2**v

#Calculation
de=(VH-VL)/q
Nq=de**2/12.0    #quantization noise

#Result
print('Normalized power for quantization noise =%.2f x 10^-6 W' %(Nq*(10**6)))

Normalized power for quantization noise =127.16 x 10^-6 W


## Example 3.30.ii, Page No 153¶

In [131]:
import math
#Find bit transmission rate

#Variable Declaration
fm=3*10.0**3
v=8.0
VH=5.0
VL=-5
q=2**v

#Calculation
fs=2*fm       #Nyquist rate
r=8*fs/1000

#Result
print('bit transmission rate %.f K bits/s' %r)


bit transmission rate 48 K bits/s


## Example 3.30.iii, Page No 153¶

In [132]:
import math
#Find  Signal to quantization noise ratio

#Variable Declaration
Nq=127.15*10**-6
Meansignal=2

#Calculation
P=Meansignal/1
SNR=P/Nq
SNRq=10*math.log10(SNR)

#Result
print('Signal to quantization noise ratio %.2f dB ' %SNRq)


Signal to quantization noise ratio 41.97 dB


## Example 3.31, Page No 154¶

In [133]:
import math
#Find  i)SNR  ii)output bit rate iii)no.of bits recorded

#Variable Declaration
N=16.0
v=16.0
fs=44.1*10**3

#Calculation
SNR=1.76+6*N
bitrate=2*v*fs
CD=outputbitrate*3600*10**-3

#Result
print('i)Out put signal noise ratio =%.2f dB' %SNR)
print('ii)output bit rate =%.3f Mbits/sec' %outputbitrate)
print('iii)no.of bits recorded in CD =%.2f gigabits' %CD)

i)Out put signal noise ratio =97.76 dB
ii)output bit rate =2.822 Mbits/sec
iii)no.of bits recorded in CD =10.16 gigabits


## Example 3.32, Page No 155¶

In [134]:
import math
#Find  output SNR
#Variable Declaration
fm=1*10.0**3
fs=32*10**3

#Calculation
FM=4*10**3     #Bandwidth
SNR=(3*fs**3)/(8*math.pi**2*fm**2*FM)    #SNR
SNRO=10*math.log10(SNR)

#Result
print('Output signal to noise ratio %.2f dB' %SNRO)

Output signal to noise ratio 24.93 dB


## Example 3.33.i, Page No 155¶

In [135]:
import math
#Find  step size

#Variable Declaration
fs=64000.0     #samples/sec
Amax=1.0       #Maximum signal amplitude
fm=3500.0      #Sample Rate

#Calculation
de=(2*math.pi*fm*Amax)/fs*1000

#Result
print('Step Size %.2f mV ' %de)

Step Size 343.61 mV


## Example 3.33ii, Page No 155¶

In [136]:
import math
#Find  Quantizatio noise power
#Variable Declaration
fs=64000.0     #sample Rate
Amax=1.0       #Maximum signal Amplitude
fm=3500.0

#Calculation
de=343.6117*10**-3      #step size
Nq=de**2/3.0             #Quantizatio noise power
Nqd=Nq*(fm/fs)*1000

#Result
print('Quantizatio noise power %.3f mW' %Nqd)

Quantizatio noise power 2.152 mW


## Example 3.33iii, Page No 155¶

In [137]:
import math
#Find SNR

#Variable Declaration
fs=64000.0
Amax=1.0
fm=3500.0
Nqd=2.1522995*10**-3

#Calculation
So=Amax**2/2
SNR=So/Nqd
SNRO=10*math.log10(SNR)

#Result
print('Output signal noise ratio dB  %.3f dB' %SNRO)

Output signal noise ratio dB  23.661 dB


## Example 3.34, Page No 156¶

In [138]:
import math
#Assuming signal is sampled at the rate 20% above Nyquist rate

#Variable Declaration
fm=4.5*10**6
q=1024.0

#Calculation
fs=1.2*2*fm           #20% above Nyquist rate
v=math.log(q,2)
r=v*fs/10**6

#Result
print('no.of bits/sec = %.f M bit/sec' %r)

no.of bits/sec = 108 M bit/sec


## Example 3.35, Page No 156¶

In [139]:
import math
#assume bandwidth of the singal is 4kHz

#Variable Declaration
fs=32000.0
A=2.0
fm=4000.0
BW=4000.0

#Calculation
de=(2*math.pi*fm*A)/fs
Nq=de**2/3
SNR=(3*fs**3)/(8*math.pi**2*fm**2*BW)

#Result
print('i)step size = %.3f M Volt' %de)
print('ii)noise power = %.3f W' %Nq)
print('iii)SNR= = %.3f ' %SNR)

i)step size = 1.571 M Volt
ii)noise power = 0.822 W
iii)SNR= = 19.454


## Example 3.36, Page No 157¶

In [140]:
import math
#assuming signal is sampled at the rate 20% above Nyquist rate

#Variable Declaration
fm=15*10**3
fs=1.2*2*fm
q=65536

#Calculation
v=math.log(q,2)
r=v*fs/1000
BW=r/2

#Result
print('i)signaling rate,= %.f K bits/sec ' %r)
print('ii)bandwidth BW min = %.f kHz ' %BW)

i)signaling rate,= 576 K bits/sec
ii)bandwidth BW min = 288 kHz


## Example 3.37, Page No 157¶

In [141]:
import math
#Find  step size,noise power

#Variable Declaration
fs=64*10**3
fm=3500.0
A=1.0

#Calculation
de=(2*math.pi*fm*A)/fs      #step size
Nq=(de**2/3)*(fm/fs)        #Granular noise power

#Result
print('i)step size = %.3f Volts' %de)
print('ii)Nq= %.5f W' %Nq)

i)step size = 0.344 Volts
ii)Nq= 0.00215 W


## Example 3.40, Page No 159¶

In [142]:
import math
#Find  step Nr,Transmission Bandwidth, SNR

#Variable Declaration
fs=4           #kHz
N=12

#Calculation
Nr=2*fs                     #Nyquest rate
Bt=1.0/2*N*fs               #Transmission Bandwidth
SNR=1.8+(6*N)

#Result
print('i)Nyquest rate = %.1f kHz' %Nr)
print('ii)Transmission Bandwidth = %.1f kHz' %Bt)
print('iii)SNR = %.1f dB' %SNR)

i)Nyquest rate = 8.0 kHz
ii)Transmission Bandwidth = 24.0 kHz
iii)SNR = 73.8 dB


## Example 3.41, Page No 159¶

In [143]:
import math
#Find  step size,noise power

#Variable Declaration
fm=3.5*10**3
fs=64*10**3
A=2.0

#Calculation
de=(2*math.pi*fm*A)/fs      #step size
Nq=(de**2/3)*(fm/fs)        #Granular noise power

#Result
print('i)step size = %.3f Volts' %de)
print('ii)Nq= %.1f  X 10^-3 W' %(Nq*10**3))

i)step size = 0.687 Volts
ii)Nq= 8.6  X 10^-3 W


## Example 3.42, Page No 159¶

In [144]:
import math
#Find  number of binay pulse per word, Bit rate, Bandwidth

#Variable Declaration
W=4.5 * 10**6                    #khz
Nr = 2 * W               #Nyquist Rate
Q = 1024
fs=10.8

#Calculation
N = math.log(Q,2)            #number of binay pulse per word
Br= N*fs                     #Bit rate
Bw= 1.0/2*Br                 #Bandwidth

#Result
print('i) Number of binay pulse per word = %.1f k bits/sec' %N)
print('ii) Bit rate = %.1f k bits/sec' %Br)
print('iii)Bandwidth= %.1f  X 10^-3 kHz' %Bw)

i) Number of binay pulse per word = 10.0 k bits/sec
ii) Bit rate = 108.0 k bits/sec
iii)Bandwidth= 54.0  X 10^-3 kHz


## Example 3.43, Page No 160¶

In [145]:
import math
#Find  number of binay pulse per word, Bit rate, Bandwidth

#Variable Declaration
W=15                 #khz
Nr = 2*W               #Nyquist Rate
Q = 65.53
fs=44.1                # Sampling rate kHz
N=16

#Calculation
Br= N*fs                    #Bit rate
Bw= 1.0/2*Br                 #Bandwidth

#Result
print('i) Number of binay pulse per word = %.3f bits' %N)
print('ii) Bit rate = %.1f k bits/sec' %Br)
print('iii)Bandwidth= %.1f kHz' %Bw)

i) Number of binay pulse per word = 16.000 bits
ii) Bit rate = 705.6 k bits/sec
iii)Bandwidth= 352.8 kHz


## Example 3.44, Page No 160¶

In [146]:
import math
#Find Number of binay pulse per word

#Variable Declaration
W=3.3                 #khz
fm = 1*10**3                #kHz
de = 250              #mV
fs=19.8                # Sampling rate kHz

#Calculation
A=(de*fs)/(2*math.pi*fm)

#Result
print('i) Number of binay pulse per word = %.3f' %A)

i) Number of binay pulse per word = 0.788


## Example 3.45, Page No 160¶

In [147]:
import math
#Find  number of binay pulse per word, Signaling rate, Bandwidth

#Variable Declaration
W=3.3                 #khz
fm = 3300               #Hz
Snq = 40              #dB
fs= 8000                # Samples/sec

#Calculation
N=math.ceil((Snq-4.8)/6)                # Number of bits per word
Q=2**N              #
r=N*fs              #Signaling rate k bits/sec
Bw=1.0/2*r

#Result
print('i) Number of bits per word = %.1f' %N)
print('ii) Signaling rate rate = %.1f k bits/sec' %(r/10**3))
print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))

i) Number of bits per word = 6.0
ii) Signaling rate rate = 48.0 k bits/sec
iii)Bandwidth= 24.0 kHz


## Example 3.46, Page No 161¶

In [148]:
import math
#Find the maximun frequency with 1 volt amplitude

#Variable Declaration
de=256*10**-3                 #V
Ts = 10*10**-6               #kHz
fm = 10              #kHz
fs= 100                # kHz
A=1                   #V

#Calculation
wm=(de/A*Ts)*10**7

#Result
print('i) maximun frequency = %.1f X 10^3 rad/sec' %wm)

i) maximun frequency = 25.6 X 10^3 rad/sec


## Example 3.47, Page No 162¶

In [149]:
import math
#Find the Signal to noise ratio

#Variable Declaration
Q=256
m=255

#Calculation
SNR=(3*Q**2)/(math.log((1+m),math.e))**2    #dB
Gc=m/(math.log(1+m))                        #Companding gain
Gc=20*math.log(Gc,10)

#Result
print('i) The Signal to noise ratio= %.1f dB' %SNR)
print('ii) The Companding gain = %.1f dB' %Gc)

i) The Signal to noise ratio= 6394.0 dB
ii) The Companding gain = 33.3 dB


## Example 3.48, Page No 162¶

In [150]:
import math
#Find  number of binay pulse per word, Signaling rate, Bandwidth

#Variable Declaration
fm=15*10**3          #kHz
Q=200
fs=2*fm

#Calculation
N=math.ceil(math.log(Q,2))
tr=N*fs           #Transmission rate kbps
Bw=1.0/2*tr

#Result
print('i) Number of bits per Samples = %.1f' %N)
print('ii) Signaling rate = %.1f k bits/sec' %(tr/10**3))
print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))

i) Number of bits per Samples = 8.0
ii) Signaling rate = 240.0 k bits/sec
iii)Bandwidth= 120.0 kHz


## Example 3.49, Page No 162¶

In [151]:
import math
#Find  number of quantization level

#Variable Declaration
tr=36.0                  #kbps
fm=3.4                 #kHz
fs=8

#Calculation
N=math.ceil(tr/fs)
Q=2**N

#Result
print('i) number of quantization level = %.1f' %Q)

i) number of quantization level = 32.0


## Example 3.50, Page No 162¶

In [152]:
import math
#Find  delta modulation

#Variable Declaration
A=1                  #V
fm=3.4                 #kHz
fs=20

#Calculation
de=1*2*math.pi*(fm/fs)

#Result
print('i) delta modulation = %.2f V' %de)

i) delta modulation = 1.07 V


## Example 3.51, Page No 163¶

In [153]:
import math
#Find  Signal to noise ratio

#Variable Declaration
W=3.5      #kHz
r=50.0      #kbps
Vpp=4      #V
fs=8

#Calculation
N=r/fs
SNR=4.8+(6.8*N)

#Result
print('i) Signal to noise ratio = %.2f V' %SNR)

i) Signal to noise ratio = 47.30 V


## Example 3.52, Page No 163¶

In [154]:
import math
#Find  Signal to noise ratio

#Variable Declaration
W=1      #MHz
fs1=3       #MHz
fs2=2.4       #MHz
Q=256
m=255

#Calculation
SNR=((3*Q**2)/(math.log((1+m),math.e))**2)
SNR1=63095.73              #SNR=38+10
Q1=math.sqrt((SNR1*((math.log(256,math.e))**2))/3)
N1=math.ceil(math.log(Q1,2))
r=N1*fs2
Bw=1.0/2*r

#Result
print('i) Number of bits/word = %.2f ' %N1)
print('ii) Bit rate = %.1f Mb/s' %r)
print('iii) Bandwidth = %.1f Mb/s' %Bw)

i) Number of bits/word = 10.00
ii) Bit rate = 24.0 Mb/s
iii) Bandwidth = 12.0 Mb/s