summaryrefslogtreecommitdiff
path: root/Digital_Communications
diff options
context:
space:
mode:
Diffstat (limited to 'Digital_Communications')
-rwxr-xr-xDigital_Communications/Chapter2.ipynb290
-rwxr-xr-xDigital_Communications/Chapter3.ipynb2238
-rwxr-xr-xDigital_Communications/Chapter4.ipynb273
-rwxr-xr-xDigital_Communications/Chapter5.ipynb105
-rwxr-xr-xDigital_Communications/Chapter6.ipynb158
-rwxr-xr-xDigital_Communications/Chapter7.ipynb431
-rwxr-xr-xDigital_Communications/Chapter8.ipynb1439
-rwxr-xr-xDigital_Communications/Chapter9.ipynb166
-rwxr-xr-xDigital_Communications/ChapterNo2.ipynb290
-rwxr-xr-xDigital_Communications/ChapterNo3.ipynb2238
-rwxr-xr-xDigital_Communications/ChapterNo4.ipynb273
-rwxr-xr-xDigital_Communications/ChapterNo5.ipynb105
-rwxr-xr-xDigital_Communications/ChapterNo6.ipynb158
-rwxr-xr-xDigital_Communications/ChapterNo7.ipynb431
-rwxr-xr-xDigital_Communications/ChapterNo8.ipynb1439
-rwxr-xr-xDigital_Communications/ChapterNo9.ipynb182
-rwxr-xr-xDigital_Communications/README.txt10
-rwxr-xr-xDigital_Communications/screenshots/Chapter1.pngbin0 -> 209810 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter2.pngbin0 -> 205124 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter2_1.pngbin0 -> 122271 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter2_2.pngbin0 -> 209679 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter2_3.pngbin0 -> 209679 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter3.pngbin0 -> 229268 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter3_1.pngbin0 -> 193440 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter3_2.pngbin0 -> 208477 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter3_3.pngbin0 -> 208477 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter4.pngbin0 -> 228102 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter4_1.pngbin0 -> 210555 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter4_2.pngbin0 -> 206602 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter4_3.pngbin0 -> 206602 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter6.pngbin0 -> 159825 bytes
-rwxr-xr-xDigital_Communications/screenshots/chapter7.pngbin0 -> 146443 bytes
32 files changed, 10226 insertions, 0 deletions
diff --git a/Digital_Communications/Chapter2.ipynb b/Digital_Communications/Chapter2.ipynb
new file mode 100755
index 00000000..9cc6d1df
--- /dev/null
+++ b/Digital_Communications/Chapter2.ipynb
@@ -0,0 +1,290 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1>Chapter 2: SAMPLING THEORY AND PULSE MODULATION<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.1, page no 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#find Nquist Rate\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given \n",
+ "pi=3.14\n",
+ "w1=50*pi\n",
+ "w2=300*pi\n",
+ "w3=100*pi\n",
+ "#w=2*%pi*f\n",
+ "\n",
+ "#Calculation\n",
+ "f1=w1/(2*pi)\n",
+ "f2=w2/(2*pi)\n",
+ "f3=w3/(2*pi)\n",
+ "fm=f2 #fm = maximum frquency is present at the signal\n",
+ "\n",
+ "#Result\n",
+ "print('maximum frquency of the signal is = %.2f Hz' %f2)\n",
+ "fs=2*fm #Nyquist rate\n",
+ "print('Nquist Rate of Signal is = %.2f Hz' %fs)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "maximum frquency of the signal is = 150.00 Hz\n",
+ "Nquist Rate of Signal is = 300.00 Hz\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.2 , page no 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Nquist Rate and Nquist time interval\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "w1=5000*math.pi\n",
+ "w2=3000*math.pi;\n",
+ "f1=w1/(2*math.pi);\n",
+ "f2=w2/(2*math.pi);\n",
+ "\n",
+ "#Calculation\n",
+ "fm=f1 #fm = maximum frquency is present at the signal\n",
+ "fs=2*fm #Nyquist rate\n",
+ "Ts=1.0/(2.0*fm) #frequncy =1/time\n",
+ "Ts=Ts*(10**3)\n",
+ "\n",
+ "#Result\n",
+ "print('maximum frquency of the signal is = %.f Hz' %f1)\n",
+ "print('Nquist Rate of the given Signal is = %.f Hz' %fs)\n",
+ "print('Nquist Interval of the given signal is = %.1f m Sec' %Ts)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "maximum frquency of the signal is = 2500 Hz\n",
+ "Nquist Rate of the given Signal is = 5000 Hz\n",
+ "Nquist Interval of the given signal is = 0.2 m Sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.3, page no 51"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find Nquist Rate \n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "f=100.0 # Frequency component of continuous-time signal\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*f #Nyquist rate\n",
+ "\n",
+ "#Result\n",
+ "print('i) To avoid aliasing Nquist Rate is = %.f Hz' %fs)\n",
+ "print('ii) It is theoretical example ')\n",
+ "print('iii) It is theoretical example ')\n",
+ "print('iv) It is theoretical example ')\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) To avoid aliasing Nquist Rate is = 200 Hz\n",
+ "ii) It is theoretical example \n",
+ "iii) It is theoretical example \n",
+ "iv) It is theoretical example \n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.4, page no 52 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Nquist Rate of Continous signal\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "w1=50*math.pi\n",
+ "w2=300*math.pi\n",
+ "w3=100*math.pi\n",
+ "\n",
+ "#Calculation\n",
+ "f1=w1/(2*math.pi)\n",
+ "f2=w2/(2*math.pi)\n",
+ "f3=w3/(2*math.pi)\n",
+ "fmax=f2 #fmax = Highest frquency component of the message signal\n",
+ "fs=2*fmax #Nyquist rate\n",
+ "\n",
+ "#Result\n",
+ "print('Highest frquency component of the message signal will be fmax = %.f Hz' %fmax)\n",
+ "print('Nquist Rate of the given Signal is = %.f Hz' %fs)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Highest frquency component of the message signal will be fmax = 150 Hz\n",
+ "Nquist Rate of the given Signal is = 300 Hz\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h3>Example 2.7, page no 67 <h3>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#find amplitude distortion at highest frquency\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "fs=9.5 #samplig frequncy\n",
+ "fmax=1 #maximum frequncy\n",
+ "t=0.2 #pulse width\n",
+ "\n",
+ "#Calculation\n",
+ "c=3*10**8\n",
+ "f=fmax\n",
+ "H1=t*(0.9933) #aperture effect at highest frequency, sinc(f*t)=0.9933 (given)\n",
+ "H1=H1*100\n",
+ "\n",
+ "#Result\n",
+ "print('|H(1)|=%.2f' %H1)\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "|H(1)|=19.87\n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.8, page no 74 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Calculate Transmission Bandwidth\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "fm=3.0*(10^3)\n",
+ "fs=8.0*(10^3) # sampling frequncy\n",
+ "\n",
+ "#Calculation\n",
+ "Ts=1.0/fs\n",
+ "t=0.1*Ts\n",
+ "BW=1.0/(2*t) #Bandwidth\n",
+ "BW=BW/(10^3)\n",
+ "\n",
+ "#Result\n",
+ "print('Transmission Bandwidth of PAM signal is kHz = %.f Khz ' %BW)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Transmission Bandwidth of PAM signal is kHz = 40 Khz \n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter3.ipynb b/Digital_Communications/Chapter3.ipynb
new file mode 100755
index 00000000..805bc62b
--- /dev/null
+++ b/Digital_Communications/Chapter3.ipynb
@@ -0,0 +1,2238 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 3: WAVEFORM CODING TECHNIQUES<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3,1 Page No 110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print('This is a Theoretical example')\t"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "This is a theoretcal example\n"
+ ]
+ }
+ ],
+ "prompt_number": 104
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3,2,i, Page No 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "#find code word length\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512 #Quantization levels\n",
+ "#q=2^v\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log10(512)/math.log10(2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"The code word legth is = %.f bits\" %v)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The code word legth is = 9 bits\n"
+ ]
+ }
+ ],
+ "prompt_number": 105
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2.ii, Page No 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#find The transmission Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512.0 #Quantization levels\n",
+ "v=9.0\n",
+ "\n",
+ "#Calculation\n",
+ "bw=v*fm*10**-6\n",
+ "\n",
+ "#Result\n",
+ "print(\"The transmission Bandwidth is = %.1f MHz\" %bw)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The transmission Bandwidth is = 37.8 MHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 106
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2.iii, Page No 111 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find Final Bit rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512.0 #Quantization levels\n",
+ "v=9.0\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm\n",
+ "r=v*fs #signaling rate\n",
+ "\n",
+ "#Result\n",
+ "print(\"Final Bit rate =%.1f x 10^6 bits/sec\" %(r/(10**6)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final Bit rate =75.6 x 10^6 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 107
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2.iv, Page No 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find Output signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512 #Quantization levels\n",
+ "v=9.0\n",
+ "\n",
+ "#Calculation\n",
+ "sn=4.8+6*v #noise in dB\n",
+ "\n",
+ "\n",
+ "print(\"Output signal to noise ratio is = %.1f dB\" %sn)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal to noise ratio is = 58.8 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 108
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.3.i, Page No 112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find bits per sample\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fmax=4*10**3\n",
+ "xmax=3.8\n",
+ "snr=100\n",
+ "\n",
+ "#Calculation\n",
+ "P=30*10**-3\n",
+ "v=(math.log10(((snr*xmax**2)/(3*P)))/(2*math.log10(2)))\n",
+ "\n",
+ "#Result\n",
+ "print(\"Number of bits required per sample are = %.2f bits\" %v)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of bits required per sample are = 6.98 bits\n"
+ ]
+ }
+ ],
+ "prompt_number": 109
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.3.ii, Page No 168"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find Transmission Bandwith\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=4*10**3 #Bandwidth of PCM\n",
+ "xmax=3.8\n",
+ "snr=100 #Signal to Noise Ratio\n",
+ "outputs=30.0\n",
+ "v=7.0\n",
+ "\n",
+ "#Calculation\n",
+ "bw=outputs*v*fm \n",
+ "r=bw*2\n",
+ "bw=bw/10**3\n",
+ "\n",
+ "#Result\n",
+ "print('Transmission Bandwith R = %.f kHz' %bw)\n",
+ "r=r/1000\n",
+ "print('Signaling rate R = %.f bits/sec' %r)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Transmission Bandwith R = 840 kHz\n",
+ "Signaling rate R = 1680 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 110
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.4, Page No 112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#find sampling rate,number of bits,bit rate,bandwidht\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "emax=0.001\n",
+ "de=2*emax\n",
+ "fm=100.0\n",
+ "xmax=10.0\n",
+ "\n",
+ "#Calculation\n",
+ "q=(2*xmax)/de\n",
+ "fs=2*fm\n",
+ "v=(math.log10(q))/math.log10(2)\n",
+ "v=math.ceil(v)\n",
+ "r=v*fs\n",
+ "\n",
+ "#Result\n",
+ "print('1. sampling Frequncy = %.f Hz ' %fs) \n",
+ "print('2. No.of bits in PCM = %.f bits ' %v) \n",
+ "print('3. sampling rate = %.f bits per second ' %r)\n",
+ "r=r/2\n",
+ "print('4. Transmission Bandwidth = %.f Hz ' %r) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. sampling Frequncy = 200 Hz \n",
+ "2. No.of bits in PCM = 14 bits \n",
+ "3. sampling rate = 2800 bits per second \n",
+ "4. Transmission Bandwidth = 1400 Hz \n"
+ ]
+ }
+ ],
+ "prompt_number": 111
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.5, Page No 113 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Bandwidth,Sampling Rate\n",
+ "\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=3.4*10**3\n",
+ "N=24\n",
+ "r=1.5*10**6\n",
+ "encoder=8\n",
+ "\n",
+ "#Calculation\n",
+ "BW=N*fm\n",
+ "BW=BW/10**3\n",
+ "r1=r/N\n",
+ "fs=r1/encoder\n",
+ "\n",
+ "#Result\n",
+ "print(\"i. Channel Bandwith is = %.2f kHz\" %BW)\n",
+ "print(\"ii. Sampling frequency is = %.2f Hz or samples per second.\" %fs)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i. Channel Bandwith is = 81.60 kHz\n",
+ "ii. Sampling frequency is = 7812.50 Hz or samples per second.\n"
+ ]
+ }
+ ],
+ "prompt_number": 112
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.6, Page No 114 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find Signal Bandwidth,Noise Ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "v=7\n",
+ "r=50*10**6\n",
+ "\n",
+ "#Calculation\n",
+ "#fs=2*fm\n",
+ "fm=r/(2*v)\n",
+ "snr=1.8+(6*v);\n",
+ "fm=fm*10**-6\n",
+ "\n",
+ "#Result\n",
+ "print('i. Maximum message Bandwidth is = %.2f MHz ' %fm)\n",
+ "print('ii. signal to quantization niose ration = %.2f dB ' %snr)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i. Maximum message Bandwidth is = 3.57 MHz \n",
+ "ii. signal to quantization niose ration = 43.80 dB \n"
+ ]
+ }
+ ],
+ "prompt_number": 113
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.7, Page No 114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#find i)bits per sample,ii)transmission rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=3*10**3\n",
+ "q=16\n",
+ "\n",
+ "#Calculation\n",
+ "v=(math.log10(q))/math.log10(2)\n",
+ "\n",
+ "#Result\n",
+ "print('i) Bits in code word= %.f bits' %v)\n",
+ "fs=2*fm\n",
+ "r=v*fs\n",
+ "print('ii) it trasmission rate= %.f x 10^3 bits per second' %(r/(10**3)))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Bits in code word= 4 bits\n",
+ "ii) it trasmission rate= 24 x 10^3 bits per second\n"
+ ]
+ }
+ ],
+ "prompt_number": 114
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.8, Page No 115"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=3.5*10**3\n",
+ "r=50*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm\n",
+ "rms=0.2\n",
+ "xmax=2\n",
+ "v=r/fs #signaling rate r=v*fs\n",
+ "v=math.ceil(v)\n",
+ "P=(rms**2)/1\n",
+ "SNR=((3*P*2**(2*v))/(xmax**2))\n",
+ "SN=10*math.log10(SNR)\n",
+ "SN=math.ceil(SN)\n",
+ "\n",
+ "#Result\n",
+ "print(\"signal to niose ratio =%.f dB\" %SN)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "signal to niose ratio =33 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 115
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.10, Page No 117 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find i)noise ratio ii)bits\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "Am=3.0\n",
+ "v=10.0\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=1.8+6*v #noise ratio \n",
+ "SN=40\n",
+ "v=(SN-1.8)/6\n",
+ "\n",
+ "#Result\n",
+ "print(\"i) Signal to Quantization noise ratio = %.1f dB\" %SNR)\n",
+ "print(\"ii) Bits required to get signal to niose ratio of 40dB = %.f \" %math.ceil(v))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Signal to Quantization noise ratio = 61.8 dB\n",
+ "ii) Bits required to get signal to niose ratio of 40dB = 7 \n"
+ ]
+ }
+ ],
+ "prompt_number": 116
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.11, Page No 117 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Maximum frequency\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "v=7\n",
+ "SNR=1.8+6*v\n",
+ "r=56*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "fs=r/v #r=v*fs signaling rate\n",
+ "fm=fs/2 #Nquset rate\n",
+ "\n",
+ "#Result\n",
+ "fm=fm/10**3\n",
+ "print(\"Maximum frequency is = %.f kHz\" %fm)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum frequency is = 4 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 117
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.14, Page No 129 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Maximum Amplitude\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3*10**3.0\n",
+ "\n",
+ "#Calculation\n",
+ "Nyquistrate=2*fm #Nyquistrate\n",
+ "fs=5*Nyquistrate #Samplingfrquency\n",
+ "Ts=1/fs #Sampling Interval\n",
+ "de=0.25 #step size\n",
+ "fm1=2*10**3.0\n",
+ "Am=de/(2*math.pi*fm1*Ts)\n",
+ "\n",
+ "#Result\n",
+ "print(\"Maximum Amplitude = %.4f Volts\" %Am)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum Amplitude = 0.5968 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 118
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.16, Page No 130"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find signaling rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs1=8*10**3.0\n",
+ "de=31.25*10**-3\n",
+ "q=64.0\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log(q,2)\n",
+ "r=v*fs1 #signaling rate\n",
+ "fm=3*10**3.0\n",
+ "A=1\n",
+ "fs2=(2*math.pi*fm*A)/(de)\n",
+ "\n",
+ "#Result\n",
+ "r=r*10**-3\n",
+ "print(\"Signaling rate of PCM is = %.f kHz\" %r)\n",
+ "fs2=fs2*10**-3\n",
+ "print(\"The signaling rate of DM is = %.2f kHz\" %fs2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signaling rate of PCM is = 48 kHz\n",
+ "The signaling rate of DM is = 603.19 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 119
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.17, Page No 131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64.0*10**3 #frequency\n",
+ "fm=2.0*10**3 #Sinosoidal input signal sample \n",
+ "fM=4.0*10**3 #bandwidth\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=(3*fs**3)/(8*math.pi**2*fm**2*fM) #Signal to noise ratio\n",
+ "SNRO=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print(\"Output signal to noise ratio = %.2f dB\" %SNRO)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal to noise ratio = 27.94 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 120
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.18, Page No 131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find signal to Quatization noise ratio \n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=8.0*10**3 #Sampling frequency\n",
+ "r=64.0*10**3 #Data Rate\n",
+ "N=8 #number of bits\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=(1.8+6*N) #signal to Quatization noise ratio\n",
+ "\n",
+ "#Result\n",
+ "print(\"Signal to Quatization noise ratio of PCM system is = %.f dB\" %SNR)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signal to Quatization noise ratio of PCM system is = 50 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 121
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.20, Page No 149"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find sampling rate,quantizing level\n",
+ "\n",
+ "#Variable Declaration\n",
+ "r=36000\n",
+ "fm=3.2*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm #Nquest rate\n",
+ "v=r/fs #r=v*fs signaling rate\n",
+ "v=math.floor(v)\n",
+ "q=2**v\n",
+ "fs1=r/v\n",
+ "\n",
+ "#Result\n",
+ "print(\"Quantizing level q = %.f \" %q)\n",
+ "fs1=fs1/1000\n",
+ "print(\"sampling rate fs = %.1f kHz \" %fs1)\n",
+ "print(\"Number of binary digits = %.f \" %v)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizing level q = 32 \n",
+ "sampling rate fs = 7.2 kHz \n",
+ "Number of binary digits = 5 \n"
+ ]
+ }
+ ],
+ "prompt_number": 122
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.21, Page No 149"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find time duration of 1bit binary encoded signal\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=input(\"Enter the Nyquist rate of Signal fs(Hz)=\")\n",
+ "q=input(\"Enter the Quantization levels q =\")\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log(q,2) #binary pulses transmitted per second\n",
+ "t=1.0/(v*fs) #Nyquist interval\n",
+ "\n",
+ "#Result\n",
+ "print('Time duration of binary signal t = %.4f sec ' %t)\n",
+ "#output\n",
+ "#Enter the Nyquist rate fs(Hz)=3\n",
+ "#Enter the Quantization levels q =5\n",
+ "#time duration of 1bit binary signal \n",
+ "#t=0.1435589 sec"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Nyquist rate of Signal fs(Hz)=23\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Quantization levels q =34\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Time duration of binary signal t = 0.0085 sec \n"
+ ]
+ }
+ ],
+ "prompt_number": 123
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.23, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNR=40\n",
+ "SNRO=10**(SNR/10)\n",
+ "\n",
+ "#SNR=3(q**2)/2, Signal to Quantization noise ratio\n",
+ "\n",
+ "#Calculation\n",
+ "q=math.sqrt((2*SNRO)/3)\n",
+ "q=math.ceil(q)\n",
+ "v=math.log(q,2) #q=2**v Quantization levels\n",
+ "v=math.ceil(v)\n",
+ "snr=1.76+6.02*v #output Signal to Quantization noise ratio\n",
+ "\n",
+ "#Result\n",
+ "print(\"Output Signal to Quantization noise ratio = %.1f dB\" %snr)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output Signal to Quantization noise ratio = 43.9 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 124
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.24.i, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Quantizing levels,minimum number of bits per sample\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNRO=30.0\n",
+ "fmin=300.0\n",
+ "fmax=3300.0\n",
+ "fs=80000.0\n",
+ "\n",
+ "#Calculation\n",
+ "#SNRO=1.76+20log10(q)\n",
+ "q=10**((SNRO-1.76)/20)\n",
+ "q=math.ceil(q)\n",
+ "v=math.log(q,2)\n",
+ "\n",
+ "#Result\n",
+ "print('Quantizing levels required is =%.f' %q)\n",
+ "print('minimum number of bits per sample are=%.1f that is approximately 5' %v)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizing levels required is =26\n",
+ "minimum number of bits per sample are=4.7 that is approximately 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 125
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.24.ii, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find minimum required bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNRO=30.0 #Signal to quantisizing noise ratio\n",
+ "fmin=300.0 #min frequency band\n",
+ "fmax=3300.0 #max frequency band\n",
+ "fs=8000.0 #Sampling rate\n",
+ "v=5.0 #Minimum number of bits per sample\n",
+ "\n",
+ "#Calculation\n",
+ "fPCM=(v*fs)/2\n",
+ "fPCM=fPCM/1000\n",
+ "\n",
+ "#Result\n",
+ "print('minimum required bandwidth =%.f kHz' %fPCM)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "minimum required bandwidth =20 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 126
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.24.iii, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Quantizing levels,minimum number of bits per sample and bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNRO=30.0 #Signal to quantisizing noise ratio\n",
+ "fmin=300.0 #min frequency band\n",
+ "fmax=3300.0 #max frequency band\n",
+ "fs=8000.0 #Sampling rate\n",
+ "\n",
+ "#Calculation\n",
+ "q=10**((SNRO+10.1)/20)\n",
+ "q=math.ceil(q)\n",
+ "v=math.log(q,2)\n",
+ "v=math.ceil(v)\n",
+ "\n",
+ "#Result\n",
+ "print('Quantizing levels need is =%.f' %q)\n",
+ "print('minimum number of bits per sample is =%.f' %v)\n",
+ "fPCM=(v*fs)/2\n",
+ "fPCM=fPCM/1000\n",
+ "print('minimum required bandwidth =%.f Khz' %fPCM)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizing levels need is =102\n",
+ "minimum number of bits per sample is =7\n",
+ "minimum required bandwidth =28 Khz\n"
+ ]
+ }
+ ],
+ "prompt_number": 127
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.27, Page No 152"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#determine the Maximum Amplitude,\n",
+ "\n",
+ "#Variable Declaration\n",
+ "de=250*10**-3\n",
+ "wm=2*math.pi*1000 \n",
+ "fs=3*10**3\n",
+ "Ts=1/fs\n",
+ "\n",
+ "#Calculation\n",
+ "Amax=(de*3*fs*2)/(wm) #Amplitude\n",
+ "SNR=(3.0*((3*6*(10**3))**3))/((8*(math.pi**2)*(10**3)**3))\n",
+ "\n",
+ "#Result\n",
+ "print('Maximum Amplitude= %.1f mV' %(Amax*(10**2)))\n",
+ "print('Signal to noise ratio = %.2f dB' %(10*math.log10(SNR)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum Amplitude= 71.6 mV\n",
+ "Signal to noise ratio = 23.46 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 128
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.29, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of bits per sample\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNR=20\n",
+ "averagepower=30*10**-3\n",
+ "SNRO=10**(SNR/10)\n",
+ "A=3.8\n",
+ "\n",
+ "#SNRO=average signal power/Quatizing power\n",
+ "#de=(2*A)/L\n",
+ "\n",
+ "#Calculation\n",
+ "L=math.sqrt((SNRO*A**2)/(3*averagepower))\n",
+ "n=math.log(L,2)\n",
+ "n=math.ceil(n)\n",
+ "\n",
+ "#Result\n",
+ "print('Bits required per sample =%.f' %n)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bits required per sample =7\n"
+ ]
+ }
+ ],
+ "prompt_number": 129
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.30.i, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Normalized power for quantization noise\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3.0*10.0**3\n",
+ "v=8.0\n",
+ "VH=5.0\n",
+ "VL=-5.0\n",
+ "q=2**v\n",
+ "\n",
+ "#Calculation\n",
+ "de=(VH-VL)/q\n",
+ "Nq=de**2/12.0 #quantization noise\n",
+ "\n",
+ "#Result\n",
+ "print('Normalized power for quantization noise =%.2f x 10^-6 W' %(Nq*(10**6)))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Normalized power for quantization noise =127.16 x 10^-6 W\n"
+ ]
+ }
+ ],
+ "prompt_number": 130
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.30.ii, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find bit transmission rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3*10.0**3\n",
+ "v=8.0\n",
+ "VH=5.0\n",
+ "VL=-5\n",
+ "q=2**v\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm #Nyquist rate\n",
+ "r=8*fs/1000\n",
+ "\n",
+ "#Result\n",
+ "print('bit transmission rate %.f K bits/s' %r)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "bit transmission rate 48 K bits/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 131
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.30.iii, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Signal to quantization noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "Nq=127.15*10**-6\n",
+ "Meansignal=2\n",
+ "\n",
+ "#Calculation\n",
+ "P=Meansignal/1\n",
+ "SNR=P/Nq\n",
+ "SNRq=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print('Signal to quantization noise ratio %.2f dB ' %SNRq)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signal to quantization noise ratio 41.97 dB \n"
+ ]
+ }
+ ],
+ "prompt_number": 132
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.31, Page No 154"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find i)SNR ii)output bit rate iii)no.of bits recorded\n",
+ "\n",
+ "#Variable Declaration\n",
+ "N=16.0\n",
+ "v=16.0\n",
+ "fs=44.1*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=1.76+6*N\n",
+ "bitrate=2*v*fs\n",
+ "outputbitrate=2*bitrate*10**-6 #including addtional 100% over head\n",
+ "CD=outputbitrate*3600*10**-3\n",
+ "\n",
+ "#Result\n",
+ "print('i)Out put signal noise ratio =%.2f dB' %SNR)\n",
+ "print('ii)output bit rate =%.3f Mbits/sec' %outputbitrate)\n",
+ "print('iii)no.of bits recorded in CD =%.2f gigabits' %CD)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)Out put signal noise ratio =97.76 dB\n",
+ "ii)output bit rate =2.822 Mbits/sec\n",
+ "iii)no.of bits recorded in CD =10.16 gigabits\n"
+ ]
+ }
+ ],
+ "prompt_number": 133
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.32, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find output SNR\n",
+ "#Variable Declaration\n",
+ "fm=1*10.0**3\n",
+ "fs=32*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "FM=4*10**3 #Bandwidth\n",
+ "SNR=(3*fs**3)/(8*math.pi**2*fm**2*FM) #SNR\n",
+ "SNRO=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print('Output signal to noise ratio %.2f dB' %SNRO)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal to noise ratio 24.93 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 134
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.33.i, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step size\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64000.0 #samples/sec\n",
+ "Amax=1.0 #Maximum signal amplitude\n",
+ "fm=3500.0 #Sample Rate\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*Amax)/fs*1000\n",
+ "\n",
+ "#Result\n",
+ "print('Step Size %.2f mV ' %de)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Step Size 343.61 mV \n"
+ ]
+ }
+ ],
+ "prompt_number": 135
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.33ii, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Quantizatio noise power \n",
+ "#Variable Declaration\n",
+ "fs=64000.0 #sample Rate\n",
+ "Amax=1.0 #Maximum signal Amplitude\n",
+ "fm=3500.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=343.6117*10**-3 #step size\n",
+ "Nq=de**2/3.0 #Quantizatio noise power\n",
+ "Nqd=Nq*(fm/fs)*1000\n",
+ "\n",
+ "#Result\n",
+ "print('Quantizatio noise power %.3f mW' %Nqd)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizatio noise power 2.152 mW\n"
+ ]
+ }
+ ],
+ "prompt_number": 136
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.33iii, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find SNR\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64000.0\n",
+ "Amax=1.0\n",
+ "fm=3500.0\n",
+ "Nqd=2.1522995*10**-3\n",
+ "\n",
+ "#Calculation\n",
+ "So=Amax**2/2\n",
+ "SNR=So/Nqd\n",
+ "SNRO=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print('Output signal noise ratio dB %.3f dB' %SNRO)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal noise ratio dB 23.661 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 137
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.34, Page No 156"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Assuming signal is sampled at the rate 20% above Nyquist rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=4.5*10**6\n",
+ "q=1024.0\n",
+ "\n",
+ "#Calculation\n",
+ "fs=1.2*2*fm #20% above Nyquist rate\n",
+ "v=math.log(q,2)\n",
+ "r=v*fs/10**6\n",
+ "\n",
+ "#Result\n",
+ "print('no.of bits/sec = %.f M bit/sec' %r)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "no.of bits/sec = 108 M bit/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 138
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.35, Page No 156"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume bandwidth of the singal is 4kHz\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=32000.0\n",
+ "A=2.0\n",
+ "fm=4000.0\n",
+ "BW=4000.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*A)/fs\n",
+ "Nq=de**2/3\n",
+ "SNR=(3*fs**3)/(8*math.pi**2*fm**2*BW)\n",
+ "\n",
+ "#Result\n",
+ "print('i)step size = %.3f M Volt' %de)\n",
+ "print('ii)noise power = %.3f W' %Nq)\n",
+ "print('iii)SNR= = %.3f ' %SNR)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)step size = 1.571 M Volt\n",
+ "ii)noise power = 0.822 W\n",
+ "iii)SNR= = 19.454 \n"
+ ]
+ }
+ ],
+ "prompt_number": 139
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.36, Page No 157"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assuming signal is sampled at the rate 20% above Nyquist rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=15*10**3\n",
+ "fs=1.2*2*fm\n",
+ "q=65536\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log(q,2)\n",
+ "r=v*fs/1000\n",
+ "BW=r/2\n",
+ "\n",
+ "#Result\n",
+ "print('i)signaling rate,= %.f K bits/sec ' %r)\n",
+ "print('ii)bandwidth BW min = %.f kHz ' %BW)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)signaling rate,= 576 K bits/sec \n",
+ "ii)bandwidth BW min = 288 kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 140
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.37, Page No 157"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step size,noise power\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64*10**3\n",
+ "fm=3500.0\n",
+ "A=1.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*A)/fs #step size\n",
+ "Nq=(de**2/3)*(fm/fs) #Granular noise power\n",
+ "\n",
+ "#Result\n",
+ "print('i)step size = %.3f Volts' %de)\n",
+ "print('ii)Nq= %.5f W' %Nq)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)step size = 0.344 Volts\n",
+ "ii)Nq= 0.00215 W\n"
+ ]
+ }
+ ],
+ "prompt_number": 141
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.40, Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step Nr,Transmission Bandwidth, SNR\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=4 #kHz\n",
+ "N=12\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=2*fs #Nyquest rate\n",
+ "Bt=1.0/2*N*fs #Transmission Bandwidth\n",
+ "SNR=1.8+(6*N) \n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print('i)Nyquest rate = %.1f kHz' %Nr)\n",
+ "print('ii)Transmission Bandwidth = %.1f kHz' %Bt)\n",
+ "print('iii)SNR = %.1f dB' %SNR)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)Nyquest rate = 8.0 kHz\n",
+ "ii)Transmission Bandwidth = 24.0 kHz\n",
+ "iii)SNR = 73.8 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 142
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.41, Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step size,noise power\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3.5*10**3\n",
+ "fs=64*10**3\n",
+ "A=2.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*A)/fs #step size\n",
+ "Nq=(de**2/3)*(fm/fs) #Granular noise power\n",
+ "\n",
+ "#Result\n",
+ "print('i)step size = %.3f Volts' %de)\n",
+ "print('ii)Nq= %.1f X 10^-3 W' %(Nq*10**3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)step size = 0.687 Volts\n",
+ "ii)Nq= 8.6 X 10^-3 W\n"
+ ]
+ }
+ ],
+ "prompt_number": 143
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.42, Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Bit rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=4.5 * 10**6 #khz\n",
+ "Nr = 2 * W #Nyquist Rate\n",
+ "Q = 1024\n",
+ "fs=10.8\n",
+ "\n",
+ "#Calculation\n",
+ "N = math.log(Q,2) #number of binay pulse per word\n",
+ "Br= N*fs #Bit rate\n",
+ "Bw= 1.0/2*Br #Bandwidth\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of binay pulse per word = %.1f k bits/sec' %N)\n",
+ "print('ii) Bit rate = %.1f k bits/sec' %Br)\n",
+ "print('iii)Bandwidth= %.1f X 10^-3 kHz' %Bw)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of binay pulse per word = 10.0 k bits/sec\n",
+ "ii) Bit rate = 108.0 k bits/sec\n",
+ "iii)Bandwidth= 54.0 X 10^-3 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 144
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.43, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Bit rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=15 #khz\n",
+ "Nr = 2*W #Nyquist Rate\n",
+ "Q = 65.53\n",
+ "fs=44.1 # Sampling rate kHz\n",
+ "N=16\n",
+ "\n",
+ "#Calculation\n",
+ "Br= N*fs #Bit rate\n",
+ "Bw= 1.0/2*Br #Bandwidth\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of binay pulse per word = %.3f bits' %N)\n",
+ "print('ii) Bit rate = %.1f k bits/sec' %Br)\n",
+ "print('iii)Bandwidth= %.1f kHz' %Bw)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of binay pulse per word = 16.000 bits\n",
+ "ii) Bit rate = 705.6 k bits/sec\n",
+ "iii)Bandwidth= 352.8 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 145
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.44, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Number of binay pulse per word\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=3.3 #khz\n",
+ "fm = 1*10**3 #kHz\n",
+ "de = 250 #mV\n",
+ "fs=19.8 # Sampling rate kHz\n",
+ "\n",
+ "#Calculation\n",
+ "A=(de*fs)/(2*math.pi*fm)\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of binay pulse per word = %.3f' %A)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of binay pulse per word = 0.788\n"
+ ]
+ }
+ ],
+ "prompt_number": 146
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.45, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Signaling rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=3.3 #khz\n",
+ "fm = 3300 #Hz\n",
+ "Snq = 40 #dB\n",
+ "fs= 8000 # Samples/sec\n",
+ "\n",
+ "#Calculation \n",
+ "N=math.ceil((Snq-4.8)/6) # Number of bits per word\n",
+ "Q=2**N #\n",
+ "r=N*fs #Signaling rate k bits/sec\n",
+ "Bw=1.0/2*r\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of bits per word = %.1f' %N)\n",
+ "print('ii) Signaling rate rate = %.1f k bits/sec' %(r/10**3))\n",
+ "print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of bits per word = 6.0\n",
+ "ii) Signaling rate rate = 48.0 k bits/sec\n",
+ "iii)Bandwidth= 24.0 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 147
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.46, Page No 161"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find the maximun frequency with 1 volt amplitude\n",
+ "\n",
+ "#Variable Declaration\n",
+ "de=256*10**-3 #V\n",
+ "Ts = 10*10**-6 #kHz\n",
+ "fm = 10 #kHz\n",
+ "fs= 100 # kHz\n",
+ "A=1 #V\n",
+ "\n",
+ "#Calculation \n",
+ "wm=(de/A*Ts)*10**7\n",
+ "\n",
+ "#Result\n",
+ "print('i) maximun frequency = %.1f X 10^3 rad/sec' %wm)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) maximun frequency = 25.6 X 10^3 rad/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 148
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.47, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find the Signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "Q=256 \n",
+ "m=255\n",
+ "\n",
+ "#Calculation \n",
+ "SNR=(3*Q**2)/(math.log((1+m),math.e))**2 #dB\n",
+ "Gc=m/(math.log(1+m)) #Companding gain\n",
+ "Gc=20*math.log(Gc,10)\n",
+ "\n",
+ "#Result\n",
+ "print('i) The Signal to noise ratio= %.1f dB' %SNR)\n",
+ "print('ii) The Companding gain = %.1f dB' %Gc)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) The Signal to noise ratio= 6394.0 dB\n",
+ "ii) The Companding gain = 33.3 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 149
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.48, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Signaling rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=15*10**3 #kHz\n",
+ "Q=200\n",
+ "fs=2*fm\n",
+ "\n",
+ "#Calculation \n",
+ "N=math.ceil(math.log(Q,2))\n",
+ "tr=N*fs #Transmission rate kbps\n",
+ "Bw=1.0/2*tr\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of bits per Samples = %.1f' %N)\n",
+ "print('ii) Signaling rate = %.1f k bits/sec' %(tr/10**3))\n",
+ "print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of bits per Samples = 8.0\n",
+ "ii) Signaling rate = 240.0 k bits/sec\n",
+ "iii)Bandwidth= 120.0 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 150
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.49, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of quantization level\n",
+ "\n",
+ "#Variable Declaration\n",
+ "tr=36.0 #kbps\n",
+ "fm=3.4 #kHz\n",
+ "fs=8\n",
+ "\n",
+ "#Calculation \n",
+ "N=math.ceil(tr/fs)\n",
+ "Q=2**N\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print('i) number of quantization level = %.1f' %Q)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) number of quantization level = 32.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 151
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.50, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find delta modulation\n",
+ "\n",
+ "#Variable Declaration\n",
+ "A=1 #V\n",
+ "fm=3.4 #kHz\n",
+ "fs=20\n",
+ "\n",
+ "#Calculation \n",
+ "de=1*2*math.pi*(fm/fs)\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print('i) delta modulation = %.2f V' %de)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) delta modulation = 1.07 V\n"
+ ]
+ }
+ ],
+ "prompt_number": 152
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.51, Page No 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=3.5 #kHz\n",
+ "r=50.0 #kbps\n",
+ "Vpp=4 #V\n",
+ "fs=8\n",
+ "\n",
+ "#Calculation \n",
+ "N=r/fs\n",
+ "SNR=4.8+(6.8*N)\n",
+ "\n",
+ "#Result\n",
+ "print('i) Signal to noise ratio = %.2f V' %SNR)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Signal to noise ratio = 47.30 V\n"
+ ]
+ }
+ ],
+ "prompt_number": 153
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.52, Page No 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=1 #MHz\n",
+ "fs1=3 #MHz\n",
+ "fs2=2.4 #MHz\n",
+ "Q=256\n",
+ "m=255\n",
+ "\n",
+ "#Calculation \n",
+ "SNR=((3*Q**2)/(math.log((1+m),math.e))**2)\n",
+ "SNR1=63095.73 #SNR=38+10\n",
+ "Q1=math.sqrt((SNR1*((math.log(256,math.e))**2))/3)\n",
+ "N1=math.ceil(math.log(Q1,2))\n",
+ "r=N1*fs2\n",
+ "Bw=1.0/2*r\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of bits/word = %.2f ' %N1)\n",
+ "print('ii) Bit rate = %.1f Mb/s' %r)\n",
+ "print('iii) Bandwidth = %.1f Mb/s' %Bw)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of bits/word = 10.00 \n",
+ "ii) Bit rate = 24.0 Mb/s\n",
+ "iii) Bandwidth = 12.0 Mb/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 154
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter4.ipynb b/Digital_Communications/Chapter4.ipynb
new file mode 100755
index 00000000..e56598ee
--- /dev/null
+++ b/Digital_Communications/Chapter4.ipynb
@@ -0,0 +1,273 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 4: DIGITAL MULTIPLEXERS<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.4, page no 190 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Caption: Sampling Rate\n",
+ "\n",
+ "#initialisation of variables\n",
+ "f1=4.0*10**3\n",
+ "f2=4.5*10**3\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "fsmin=(2*f2)/1000\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\" Sampling rate =%.2f kHz\" %fsmin)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Sampling rate =9.00 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.5, Page No 190 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Caption: Nyquest rate,Signaling rate,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "f1=3000.0\n",
+ "f4=1000.0\n",
+ "f2=1000.0\n",
+ "f3=1000.0\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "#Nyquest rate\n",
+ "nq1=2*f1\n",
+ "nq2=2*f2\n",
+ "nq3=2*f3\n",
+ "nq4=2*f4\n",
+ "\n",
+ "#RESULTS\n",
+ "print('i. Nyquest rate of x1 =%.2fkHz' %nq1)\n",
+ "print('ii. Nyquest rate of x2 =%.2fkHz' %nq2)\n",
+ "print('iii. Nyquest rate of x3 =%.2fkHz' %nq3)\n",
+ "print('iv. Nyquest rate of x4 =%.2fkHz' %nq4)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i. Nyquest rate of x1 =6000.00kHz\n",
+ "ii. Nyquest rate of x2 =2000.00kHz\n",
+ "iii. Nyquest rate of x3 =2000.00kHz\n",
+ "iv. Nyquest rate of x4 =2000.00kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.6, Page No 190 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find The spacing between two successive pules\n",
+ "\n",
+ "#initialisation of variables\n",
+ "samplingrate=8000.0\n",
+ "totalsignals=24+1\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "t=1/samplingrate\n",
+ "T=t/totalsignals\n",
+ "T=T*10**6 #time is now u sec\n",
+ "space=T-1\n",
+ "\n",
+ "#RESULTS\n",
+ "print('The spacing between two successive pules %.f u sec' %space)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The spacing between two successive pules 4 u sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.7, Page No 191"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find signaling rate ,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "N=6.0\n",
+ "fm=5000.0\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "r=2*fm #sampling rate\n",
+ "sr=N*r #signalingrate\n",
+ "BW=N*fm #Bandwith\n",
+ "sr=sr/1000\n",
+ "BW=BW/1000\n",
+ "\n",
+ "#RESULTS\n",
+ "print('Signaling rate %.f K bits/sec' %sr)\n",
+ "print('Bandwith to avoid the cross talk in TDM is %.f kHz' %BW)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signaling rate 60 K bits/sec\n",
+ "Bandwith to avoid the cross talk in TDM is 30 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.9, Page No 198"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find signaling rate ,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "N=4.0\n",
+ "x=24 #bits/frame\n",
+ "D=1152\n",
+ "s=1.0/3\n",
+ "r=1.544*10**6\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "r0=N*r*((D+x)/(D-s*N))\n",
+ "\n",
+ "#RESULTS\n",
+ "print('Output bit rate %.2f MB/sec' %(r0/(10**6)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output bit rate 6.31 MB/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.10, Page No 198"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find signaling rate ,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "N=24.0\n",
+ "x=72.0 #bits\n",
+ "D=192 #message and stuff bits\n",
+ "s=1.0/3\n",
+ "r=64 #kb/sec\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "r0=N*r*((D+x)/(D-s*N))\n",
+ "r1=((N*r)/r0)*100\n",
+ "\n",
+ "#RESULTS\n",
+ "print('i) Output bit rate %.2f MB/sec' %(r0/(10**3)))\n",
+ "print('iI) Throughput efficiency is = %.2f percent' %r1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Output bit rate 2.20 MB/sec\n",
+ "iI) Throughput efficiency is = 69.70 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter5.ipynb b/Digital_Communications/Chapter5.ipynb
new file mode 100755
index 00000000..bf535beb
--- /dev/null
+++ b/Digital_Communications/Chapter5.ipynb
@@ -0,0 +1,105 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 5: DIGTIAL BASEBAND TRANSMISSION<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.12, Page No 249 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find The roll of factor alpha\n",
+ "\n",
+ "#initialisation of variables\n",
+ "datarate=0.1*10**6\n",
+ "fB=75000.0 #bandwidth\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Tb=1/datarate\n",
+ "alpha=2*fB*Tb-1\n",
+ "\n",
+ "#RESULTS\n",
+ "print('The roll out factor alpha = = %.1f ' %alpha)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The roll out factor alpha = = 0.5 \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.13, Page No 249"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find The Transmission bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "q=128.0\n",
+ "alpha=0.2\n",
+ "n=math.log(q,2)\n",
+ "fm=2000.0\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Nq=2*fm\n",
+ "fs=1.25*Nq\n",
+ "N=8.0\n",
+ "total=N*fs\n",
+ "bitrate=7*total\n",
+ "fB=((1+alpha)*bitrate)/2\n",
+ "fB=fB/1000\n",
+ "#RESULTS\n",
+ "print('The minimum transmission Bandwidth required = %.f kHz' %fB)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The minimum transmission Bandwidth required = 168 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter6.ipynb b/Digital_Communications/Chapter6.ipynb
new file mode 100755
index 00000000..fd5f6716
--- /dev/null
+++ b/Digital_Communications/Chapter6.ipynb
@@ -0,0 +1,158 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 6: DIGITAL MODULATION TECHNIQUES<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.5, Page No 327"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "#Symbol rate of transmission and bandwidth \n",
+ "\n",
+ "#initialisation of variables\n",
+ "fb=1.0 #MHz\n",
+ "Tb=1/fb #bit period ms\n",
+ "N=4\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Ts1=Tb\n",
+ "Bw1=2*fb\n",
+ "Ts2=Tb*2\n",
+ "Tr2=(1.0/2)*1000 #Symbols/sec\n",
+ "Bw2=1/Tb\n",
+ "Ts3=N*Tb\n",
+ "Tr3=(1.0/4)*1000\n",
+ "Bw3=(2.0*fb)/N\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"In BPSK\")\n",
+ "print(\"The symbol rate of transmission is = %.f X 10^6 symbol/sec \" %Ts1)\n",
+ "print(\"The Bandwidth is = %.f MHz \" %Bw1)\n",
+ "print(\"In QPSK\")\n",
+ "print(\"The symbol rate of transmission is = %.f X 10^3 symbol/sec \" %Tr2)\n",
+ "print(\"The Bandwidth is = %.f MHz \" %Bw2)\n",
+ "print(\"In 16-ary PSK\")\n",
+ "print(\"The symbol rate of transmission is = %.f X 10^3 symbol/sec \" %Tr3)\n",
+ "print(\"The Bandwidth is = %.f kHz \" %(Bw3*1000))\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "In BPSK\n",
+ "The symbol rate of transmission is = 1 X 10^6 symbol/sec \n",
+ "The Bandwidth is = 2 MHz \n",
+ "In QPSK\n",
+ "The symbol rate of transmission is = 500 X 10^3 symbol/sec \n",
+ "The Bandwidth is = 1 MHz \n",
+ "In 16-ary PSK\n",
+ "The symbol rate of transmission is = 250 X 10^3 symbol/sec \n",
+ "The Bandwidth is = 500 kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.6, Page No 328"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "fb=90 #MHz\n",
+ "Bw=20 #Mb/s\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "N=(2*fb)/Bw\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"Number of bits required = %.f \" %N)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of bits required = 9 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.12, Page No 357"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Tb=0.1 #msec\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "fb=1/Tb\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"Transmission bandwidth = %.f kHz\" %fb)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Transmission bandwidth = 10 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter7.ipynb b/Digital_Communications/Chapter7.ipynb
new file mode 100755
index 00000000..7c33676a
--- /dev/null
+++ b/Digital_Communications/Chapter7.ipynb
@@ -0,0 +1,431 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 7: PERFORMANCE ANALYSIS OF DIGITAL COMMUNICATION SYSTEMS<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.15, Page No 414"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "#initialisation of variables\n",
+ "T=1.0*10**-6 #ms\n",
+ "A=10.0*10**-3\n",
+ "N=1*10**-11\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Eb=((A**2)*T)/2.0\n",
+ "Epb=math.sqrt(Eb/N)\n",
+ "Pb=(1.0/2)*math.erfc(Epb)*(1.0/4)\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"Bit error probability = %.2f X 10^-4 \" %(Pb*(10**4)))\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bit error probability = 1.96 X 10^-4 \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.16, Page No 420"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Br=25*10**6 #bits/sec\n",
+ "N=2*10**-20 #Power spectral density of noise\n",
+ "A=1.0*10**-6\n",
+ "Ps=1*10**-12 # Normalized power\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Tb=1.0/Br\n",
+ "Ps=(A**2)/2.0\n",
+ "Pe=1.0/2*(math.erfc((0.6*Ps*Tb)/N))\n",
+ "#RESULTS\n",
+ "print(\"Average probability of bit error is Pe= %.2f X 10^-4 \" %(Pe*10))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Average probability of bit error is Pe= 1.98 X 10^-4 \n"
+ ]
+ }
+ ],
+ "prompt_number": 45
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.17, Page No 423"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find probability of error\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=2.0\n",
+ "N0=2.0*10**-4 #power sepctral density\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Tmin=(6.76*N0)/4\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The min time for which the signal should be extended is Tmin= %.3f X 10^-3 msec \" %(Tmin*10**3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The min time for which the signal should be extended is Tmin= 0.338 X 10^-3 msec \n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.20, Page No 428"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#The average carrier\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Pe=10**-4\n",
+ "N0=2*10**10\n",
+ "T=1.0/10**6\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "E=6.76*N0\n",
+ "P=E/T\n",
+ "Eb=8.5171*N0\n",
+ "P2=Eb/T\n",
+ "\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The average carrier = %.3f X 10^-3 mW \" %(P2/10**17))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The average carrier = 1.703 X 10^-3 mW \n"
+ ]
+ }
+ ],
+ "prompt_number": 47
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.21, Page No 430"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#The average carrier\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=0.2*10**-3 #V\n",
+ "T=2*10**-6\n",
+ "N0=2*10**-15\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Pe=(math.sqrt((A**2*T)/4*N0))\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The average carrier = %.3f X 10^-4 mW \" %(Pe*10**15))\n",
+ "print(\"Approximation error\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The average carrier = 6.325 X 10^-4 mW \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 48
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.29, Page No 447"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=1.0\n",
+ "N0=2.0*10**-5 #power sepctral density\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "T=((3.71**2)*2*N0)/(A**2)\n",
+ "Br=1/T\n",
+ "#Results\n",
+ "print(\"Bit rate Br= %.2f k bits/sec\" %(Br/(10**3)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bit rate Br= 1.82 k bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 49
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.31, Page No 448"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Pe=10.0**-4 #probability of error of PSK\n",
+ "N0=2.0*10**-10\n",
+ "Br=10**6 #Bit Rate\n",
+ "\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "T=1.0/Br\n",
+ "E=N0*6.76\n",
+ "P=E/T\n",
+ "Eb=8.5171*N0\n",
+ "Pb=Eb/T\n",
+ "#Results\n",
+ "print(\"i) PSK system The required carrier power = %.2f mW\" %(P*10**3))\n",
+ "print(\"ii) DPSK system The required carrier power = %.2f mW\" %(Pb*10**3))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) PSK system The required carrier power = 1.35 mW\n",
+ "ii) DPSK system The required carrier power = 1.70 mW\n"
+ ]
+ }
+ ],
+ "prompt_number": 50
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.32, Page No 450"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=0.2*10**-3 #V\n",
+ "T=2*10**-6 #Sec\n",
+ "N0=2*10**-15\n",
+ "\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "x=math.sqrt((A**2*T)/(4*N0))\n",
+ "Pe=(1.0/2)*math.erfc(x/math.sqrt(2.0))\n",
+ "\n",
+ "#Results\n",
+ "print(\"Probability of error = %.2f X 10^-4\" %(Pe*10**4))\n",
+ "#print(\"Channel Bandwidth = %.5f MHz\" %BW)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Probability of error = 7.83 X 10^-4\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.36, Page No 453"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Ap=1 #mV\n",
+ "En=192.3 #mV\n",
+ "Arms=707 #mV\n",
+ "\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Z=Arms/En\n",
+ "Pe=1.0/2*(math.erfc(math.sqrt(2)*(Z/math.sqrt(2))))\n",
+ "\n",
+ "#Results\n",
+ "print(\"Probability of error is %.7f \" %Pe)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Probability of error is 0.0000001 \n"
+ ]
+ }
+ ],
+ "prompt_number": 52
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.37, Page No 454"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Br=2.08*10**-6 #Bit Rate\n",
+ "N0=2*10**-8\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Eb=(math.sqrt(3.3))/(5*10**7) #Eb=bit energy\n",
+ "Ps=Eb*Br\n",
+ "BW=2*Br #Bandwidth\n",
+ "Es=286.39*N0\n",
+ "Ps2=(Es*Br)/2\n",
+ "BW2=(2*Br)/4\n",
+ "\n",
+ "#Results\n",
+ "print(\"i) BPSK THe transmission bandwidth = %.2f MHz\" %(BW*10**6)) \n",
+ "print(\"ii) For 16 ary PSK THe transmission bandwidth = %.2f MHz\" %(BW2*10**6)) \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) BPSK THe transmission bandwidth = 4.16 MHz\n",
+ "ii) For 16 ary PSK THe transmission bandwidth = 1.04 MHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 53
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter8.ipynb b/Digital_Communications/Chapter8.ipynb
new file mode 100755
index 00000000..52d8741e
--- /dev/null
+++ b/Digital_Communications/Chapter8.ipynb
@@ -0,0 +1,1439 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 8: INFORMATION THEORY<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.1, Page No 464"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "#Find Information Content of Each Symbol\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/8.0\n",
+ "\n",
+ "#Calculation\n",
+ "#information content of each symbol\n",
+ "Ix1=math.log(1/px1,2)\n",
+ "Ix2=math.log(1/px2,2)\n",
+ "Ix3=math.log(1/px3,2)\n",
+ "Ix4=math.log(1/px4,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"Information Content tI(x1)= %.2f bit\" %Ix1)\n",
+ "print(\" tI(x2)= %.f bits\" %Ix2)\n",
+ "print(\" tI(x3)= %.f bits\" %Ix3)\n",
+ "print(\" tI(x4)= %.f bits\" %Ix4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Information Content tI(x1)= 1.00 bit\n",
+ " tI(x2)= 2 bits\n",
+ " tI(x3)= 3 bits\n",
+ " tI(x4)= 3 bits\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.2, Page No 464"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find amount of Information\n",
+ "#Variable Declaration\n",
+ "#Calculation\n",
+ "pxi=1/4.0\n",
+ "Ixi=(math.log10(1/pxi))/math.log10(2)\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The amount of Information I(Xi)= %.f \" %Ixi)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The amount of Information I(Xi)= 2 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.3, Page No 464"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Amount of Information\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/2.0\n",
+ "\n",
+ "#Calculation\n",
+ "Ix1=math.log(1/px1,2) #entropy\n",
+ "Ix2=math.log(1/px2,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"The amount of Information I(X1)= %.f bit\" %Ix1)\n",
+ "print(\"The amount of Information I(X2)= %.f bit\" %Ix2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The amount of Information I(X1)= 1 bit\n",
+ "The amount of Information I(X2)= 1 bit\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.4, Page No 465"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Amount of Information \n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/4.0\n",
+ "px2=3/4.0\n",
+ "\n",
+ "#Calculation\n",
+ "Ix1=math.log(1/px1,2)\n",
+ "Ix2=math.log(1/px2,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"The amount of Information I(X1)= %.f bit\" %Ix1)\n",
+ "print(\"The amount of Information I(X2)= %.2f bit\" %Ix2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The amount of Information I(X1)= 2 bit\n",
+ "The amount of Information I(X2)= 0.42 bit\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.9, Page No 468 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Entropy,Amount of information\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.4\n",
+ "px2=0.3\n",
+ "px3=0.2\n",
+ "px4=0.1\n",
+ "\n",
+ "#Calculation\n",
+ "HX=-px1*math.log(px1,2)-px2*math.log(px2,2)-px3*math.log(px3,2)-px4*math.log(px4,2)\n",
+ "Px1x2x1x3=px1*px2*px1*px3\n",
+ "Ix1x2x1x3=-math.log(Px1x2x1x3,2)\n",
+ "Px4x3x3x2=px4*px3*px3*px2\n",
+ "Ix4x3x3x2=-math.log(Px4x3x3x2,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\" \\n Entropy H(X) = %.2f bits/symbol \" %HX)\n",
+ "print(\"The amount of Information I(x1x2x1x3)= %.2f bits/symbol\" %Ix1x2x1x3)\n",
+ "print(\" I(x4x3x3x2) = %.2f bits/symbol \" %Ix4x3x3x2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " \n",
+ " Entropy H(X) = 1.85 bits/symbol \n",
+ "The amount of Information I(x1x2x1x3)= 6.70 bits/symbol\n",
+ " I(x4x3x3x2) = 9.70 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.13, Page No 471"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find information rate the telegraphic source\n",
+ "\n",
+ "#Variable Declaration\n",
+ "pdash=1/3.0\n",
+ "pdot=2/3.0\n",
+ "tdot=0.2\n",
+ "tdash=0.6\n",
+ "tspace=0.2\n",
+ "\n",
+ "#Calculation\n",
+ "HX=-pdash*math.log(pdash,2)-pdot*math.log(pdot,2)\n",
+ "Ts=pdot*tdot+pdash*tdash+tspace\n",
+ "r=1/Ts\n",
+ "R=r*HX\n",
+ "\n",
+ "#Result\n",
+ "print('Average rate of information R = %.2f bits/s' %R)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Average rate of information R = 1.72 bits/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.14, Page No 471"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find information rate of the source\n",
+ "\n",
+ "f=input('Enter the frequncy f=')\n",
+ "px1=1/8.0\n",
+ "px2=1/8.0\n",
+ "px3=3/8.0\n",
+ "px4=3/8.0\n",
+ "\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2) #entropy of the source\n",
+ "R=2*f*HX #r=2*f\n",
+ "print('information rate R= %.1f bits/sec ' %R) #f=signal bandwidth\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the frequncy f=34\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "information rate R= 123.2 bits/sec \n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.15, Page No 472"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find information rate of the source\n",
+ "#all symbols are equally likely\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/2.0\n",
+ "px3=1/2.0\n",
+ "px4=1/2.0\n",
+ "\n",
+ "#Calculation\n",
+ "f=input('Enter the frequncy of system fm(in Hz) =')\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)\n",
+ "\n",
+ "#Result\n",
+ "print('\\n Entropy H(X) =%.f bits/symbol ' %HX)\n",
+ "R=2*f*HX\n",
+ "print('information rate =%.f bits/sec' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the frequncy of system fm(in Hz) =45\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " Entropy H(X) =2 bits/symbol \n",
+ "information rate =180 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.16, Page No 473"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find source entropy ,information rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#probability symbols\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/16.0\n",
+ "px5=1/16.0\n",
+ "Tb=10.0**-3\n",
+ "\n",
+ "#Calculation\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4)+px5*math.log(1/px5)\n",
+ "\n",
+ "#Result\n",
+ "print('1. source entropy H(X) = %.2f bits/symbol ' %HX) #source entropy\n",
+ "r=1.0/Tb\n",
+ "R=r*HX #information rate\n",
+ "print(' 2. Information rate R = %.2f bits/sec ' %R)\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. source entropy H(X) = 1.72 bits/symbol \n",
+ " 2. Information rate R = 1721.57 bits/sec \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.17, Page No 473"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume if there are 16 outcomes per second\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/16.0\n",
+ "px5=1/16.0\n",
+ "r=16.0\n",
+ "\n",
+ "#Calculation\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)+px5*math.log(1/px5,2)\n",
+ "\n",
+ "#Result\n",
+ "print('1. Entropy H(X) = %.2f bits/symbol ' %HX) #source entropy\n",
+ "\n",
+ "R=r*HX\n",
+ "print('2., Information rate R = %.f bits/sec' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. Entropy H(X) = 1.88 bits/symbol \n",
+ "2., Information rate R = 30 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.18, Page No 474"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#determine entropy ,information rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/4.0\n",
+ "px2=1/5.0\n",
+ "px3=1/5.0\n",
+ "px4=1/10.0\n",
+ "px5=1/10.0\n",
+ "px6=1/20.0\n",
+ "px7=1/20.0\n",
+ "px8=1/20.0\n",
+ "f=10*10**3.0\n",
+ "fs=10*2*10**3.0\n",
+ "\n",
+ "#Calculation\n",
+ "#entropy\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)+px5*math.log(1/px5,2)+px6*math.log(1/px6,2)+px7*math.log(1/px7,2)+px8*math.log(1/px8,2) \n",
+ "\n",
+ "#Result\n",
+ "print('bits/message H(X) = %.2f ' %HX)\n",
+ "r=fs\n",
+ "R=r*HX #information rate\n",
+ "print('bits/sec R = %.2f' %R)\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "bits/message H(X) = 2.74 \n",
+ "bits/sec R = 54828.92\n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.19, Page No 476 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "from array import *\n",
+ "#Find Channel Matrix,joint probability\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.5\n",
+ "px2=0.5\n",
+ "py1x1=0.9\n",
+ "py2x1=0.1\n",
+ "py1x2=0.2\n",
+ "py2x2=0.8\n",
+ "PYX=[[py1x1,py2x1],[py1x2,py2x2]]\n",
+ "PX=[[px1,px2]]\n",
+ "PY = [[0,0],\n",
+ " [0,0]]\n",
+ "PXY = [[0,0],\n",
+ " [0,0]]\n",
+ "\n",
+ "for i in range(len(PYX)):\n",
+ " # iterate through columns of Y\n",
+ " for j in range(len(PX[0])):\n",
+ " # iterate through rows of Y\n",
+ " for k in range(len(PX)):\n",
+ " PY[i][j] += PYX[i][k] * PX[k][j]\n",
+ "print(' PY ARRAY = \\n')\n",
+ "for r in PY:\n",
+ " print(r)\n",
+ "PXd=[[px1,0],[0,px2]]\n",
+ "\n",
+ "\n",
+ "for i in range(len(PXd)):\n",
+ " # iterate through columns of Y\n",
+ " for j in range(len(PYX[0])):\n",
+ " # iterate through rows of Y\n",
+ " for k in range(len(PYX)):\n",
+ " PXY[i][j] += PXd[i][k] * PYX[k][j]\n",
+ "\n",
+ " \n",
+ "print(' \\n PXY ARRAY = \\n')\n",
+ "for r in PXY:\n",
+ " print(r)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " PY ARRAY = \n",
+ "\n",
+ "[0.45, 0.45]\n",
+ "[0.1, 0.1]\n",
+ " \n",
+ " PXY ARRAY = \n",
+ "\n",
+ "[0.45, 0.05]\n",
+ "[0.1, 0.4]\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.35, Page No 498"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Channel is aproximated by the AWGN Channel\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=4000.0\n",
+ "S=0.1*10**-3\n",
+ "n=2*10**-12\n",
+ "\n",
+ "#Calculation\n",
+ "N=n*B\n",
+ "C=B*math.log(1+(S/N),2) #Capacity of Channel\n",
+ "C=C/1000.0\n",
+ "#Result\n",
+ "print(' Capacity of Channel C=%.3f(10^3) b/s ' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Capacity of Channel C=54.439(10^3) b/s \n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36i, Page No 499"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=4000.0\n",
+ "fs=2*fm\n",
+ "n=1.25\n",
+ "\n",
+ "#Calculation\n",
+ "r=fs*n\n",
+ "pxi=1/256.0\n",
+ "HX=-math.log(pxi,2)\n",
+ "R=r*HX\n",
+ "R=R/1000\n",
+ "print('Information Rate R= %.f kb/s' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Information Rate R= 80 kb/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36ii, Page No 499"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=10*10**3.0\n",
+ "SN=20.0\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=10**(SN/10.0)\n",
+ "C=B*math.log(1+(SNR),2)\n",
+ "C=C/1000\n",
+ "\n",
+ "#Result\n",
+ "print('The channel capacity = %.2f 10^3 b/s' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The channel capacity = 66.58 10^3 b/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36iii, Page No 499"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "C=8*10**4.0\n",
+ "B=10**4.0\n",
+ "\n",
+ "#Calculation\n",
+ "SN=2**(C/B)-1\n",
+ "SNR=10*math.log(SN,10) #SNR\n",
+ "\n",
+ "#Result\n",
+ "print(' The S/N ratio required for error-free transmission =%.2f dB ' %SNR) #required SNR is greater that 24.064\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The S/N ratio required for error-free transmission =24.07 dB \n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36iv, Page No 499 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SN=20.0\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=10**(SN/10.0)\n",
+ "C=8*10**4.0\n",
+ "B=C/(math.log(1+SNR,2)) #Bandwidth\n",
+ "B=B/1000\n",
+ "\n",
+ "#Result\n",
+ "print('Bandwidth required for AWGN channel B =%.2f kHz ' %B)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bandwidth required for AWGN channel B =12.02 kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.37, Page No 502"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find code efficiency,redundancy\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.9\n",
+ "px2=0.1\n",
+ "n1=1.0\n",
+ "n2=1.0\n",
+ "\n",
+ "#Calculation\n",
+ "L=px1*n1+px2*n2 #code leght\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)\n",
+ "n=(HX/L) #code efficiency\n",
+ "n=n*100\n",
+ "\n",
+ "print('Code efficiency = %.1f percent' %n)\n",
+ "r=(100-n) #code reduncy\n",
+ "print('Code redundancy = %.1f percent' %r)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Code efficiency = 46.9 percent\n",
+ "Code redundancy = 53.1 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.38, Page No 502"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find code efficiency,redundancy\n",
+ "\n",
+ "#Variable Declaration\n",
+ "pa1=0.81\n",
+ "pa2=0.09 \n",
+ "pa3=0.09\n",
+ "pa4=0.01 \n",
+ "n1=1\n",
+ "n2=2 \n",
+ "n3=3\n",
+ "n4=3 \n",
+ "\n",
+ "#Calculation\n",
+ "L=pa1*n1+pa2*n2+pa3*n3+pa4*n4\n",
+ "HX2=pa1*math.log(1/pa1,2)+pa2*math.log(1/pa2,2)+pa3*math.log(1/pa3,2)+pa4*math.log(1/pa4,2)\n",
+ "n=HX2/L*100\n",
+ "\n",
+ "#Result\n",
+ "print(' code efficiency = %.2f percent' %n)\n",
+ "\n",
+ "r=(100-n) #code reduncy\n",
+ "print(' code redundancy = %.1f percent' %r)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " code efficiency = 72.71 percent\n",
+ " code redundancy = 27.3 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.44, Page No 507"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find efficiency of the code\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/8.0\n",
+ "n1=1.0\n",
+ "n2=2.0\n",
+ "n3=3.0\n",
+ "n4=3.0\n",
+ "\n",
+ "#Calculation\n",
+ "#information content of each symbol\n",
+ "Ix1=-math.log(px1,2)\n",
+ "Ix2=-math.log(px2,2)\n",
+ "Ix3=-math.log(px3,2)\n",
+ "Ix4=-math.log(px4,2)\n",
+ "\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)\n",
+ "L=px1*n1+px2*n2+px3*n3+px4*n4\n",
+ "\n",
+ "n=HX/L*100\n",
+ "\n",
+ "#Result\n",
+ "print('Ccode efficiency = %.f Percent' %n)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Ccode efficiency = 100 Percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.50, Page No 512"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy ,information rate\n",
+ "#If there are 16 outcomes per second\n",
+ "\n",
+ "#Variable Declaration\n",
+ "P1=1/2.0\n",
+ "P2=1/4.0\n",
+ "P3=1/8.0\n",
+ "P4=1/16.0\n",
+ "P5=1/32.0\n",
+ "P6=1/32.0\n",
+ "r=16 #message rate\n",
+ "\n",
+ "#Calculation\n",
+ "H=P1*math.log(1/P1,2)+P2*math.log(1/P2,2)+P3*math.log(1/P3,2)+P4*math.log(1/P4,2)+P5*math.log(1/P5,2)+P6*math.log(1/P6,2)\n",
+ "#Entropy of system\n",
+ "\n",
+ "#Result\n",
+ "print('1. Entropy of system H = %.2f bits/message ' %H)\n",
+ "R=H*r #R=Entropy*message rate\n",
+ "print(' 2. Information rate R = %.f bits/sec ' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. Entropy of system H = 1.94 bits/message \n",
+ " 2. Information rate R = 31 bits/sec \n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.51, Page No 512"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Calculate H(X) ,H(Y)\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.3\n",
+ "px2=0.4\n",
+ "px3=0.3\n",
+ "\n",
+ "#Calculation\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2) #Entropy of X\n",
+ "\n",
+ "\n",
+ "print(' 1.Entropy of X H(X)=%.3f bits/symbol ' %HX)\n",
+ "\n",
+ "PYX=[[0.8, 0.2, 0],[ 0, 1, 0],[ 0, 0.3, 0.7]]\n",
+ "PX=[[px1, px2, px3]]\n",
+ "PXY = [[0,0,0],\n",
+ " [0,0,0],\n",
+ " [0,0,0]]\n",
+ "\n",
+ "for i in range(len(PYX)):\n",
+ " # iterate through columns of PXd\n",
+ " for j in range(len(PX[0])):\n",
+ " # iterate through rows of PYX\n",
+ " for k in range(len(PX)):\n",
+ " PXY[i][j] += PYX[i][k] * PX[k][j]\n",
+ "\n",
+ "py1=PXY[0][0]\n",
+ "py2=PXY[0][1]\n",
+ "py3=PXY[0][2]\n",
+ "HY=py1*math.log(1/py1,2)+py2*math.log(1/py2,2)+py3*math.log(1/py3,2) #Entropy of Y\n",
+ "print(' 2. Entropy of Y H(Y)= %.2f bits/symbol ' %HY)\n",
+ "print('Approximation error')\t\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1.Entropy of X H(X)=1.571 bits/symbol \n",
+ " 2. Entropy of Y H(Y)= 1.51 bits/symbol \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.52, Page No 513"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source ,entropy of second order extension\n",
+ "\n",
+ "#Variable Declaration\n",
+ "P1=0.7\n",
+ "P2=0.15\n",
+ "P3=0.15\n",
+ "\n",
+ "#Calculation\n",
+ "HX=P1*math.log(1/P1,2)+P2*math.log(1/P2,2)+P3*math.log(1/P3,2) #Entropy of source\n",
+ "print(' 1. Entropy of system H(X)=%.2f bits/symbol ' %HX)\n",
+ "#H(X^n)=n*H(X)\n",
+ "n=2 #for second order\n",
+ "HX2=n*HX\n",
+ "\n",
+ "#Result\n",
+ "print(' 2. Entropy of second order system extension of source can be H(X^2)=%.2f bits/symbol ' %(HX*2))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1. Entropy of system H(X)=1.18 bits/symbol \n",
+ " 2. Entropy of second order system extension of source can be H(X^2)=2.36 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.54, Page No 514"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "S0=1/3.0\n",
+ "S1=1/6.0\n",
+ "S2=1/4.0\n",
+ "S3=1/4.0\n",
+ "\n",
+ "#Calculation\n",
+ "HX=S0*math.log(1/S0,2)+S1*math.log(1/S1,2)+S2*math.log(1/S2,2)+S3*math.log(1/S3,2) #EntroSy of source\n",
+ "\n",
+ "#Result\n",
+ "print(' Entropy of system H(X)=%.2f bits/symbol ' %HX)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Entropy of system H(X)=1.96 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.56, Page No 515"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Information capacity of telephone\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=3.4*10**3\n",
+ "SNR=30.0\n",
+ "\n",
+ "#Calculation\n",
+ "SN=10**(SNR/10)\n",
+ "C=B*math.log(1+SN,2) #Information capacity\n",
+ "C=C/1000\n",
+ "\n",
+ "#Result\n",
+ "print(' Information capacity of telephone is C = %.2f kbps ' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Information capacity of telephone is C = 33.89 kbps \n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.59, Page No 516"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "S0=1/3.0\n",
+ "S1=1/6.0\n",
+ "S2=1/4.0\n",
+ "S3=1/4.0\n",
+ "\n",
+ "#Calculation\n",
+ "HX=S0*math.log(1/S0,2)+S1*math.log(1/S1,2)+S2*math.log(1/S2,2)+S3*math.log(1/S3,2) #EntroSy of source\n",
+ "\n",
+ "#Result\n",
+ "print(' Entropy of system H(X)=%.2f bits/symbol ' %HX)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Entropy of system H(X)=1.96 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.60, Page No 516"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "m1=1/2.0\n",
+ "m2=1/4.0\n",
+ "m3=1/8.0\n",
+ "m4=1/16.0\n",
+ "m5=1/16.0\n",
+ "\n",
+ "#Calculation\n",
+ "L=(m1*1)+(m2*2)+(m3*3)+(2*(m4)*4)\n",
+ "\n",
+ "#Result\n",
+ "print(' Average number of bits per message =%.2f bits ' %L)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Average number of bits per message =1.88 bits \n"
+ ]
+ }
+ ],
+ "prompt_number": 27
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.61, Page No 517"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Information capacity of telephone\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=3.4*10**3\n",
+ "SNR=30.0\n",
+ "\n",
+ "#Calculation\n",
+ "SN=10**(SNR/10)\n",
+ "C=B*math.log(1+SN,2) #Information capacity\n",
+ "C=C/1000\n",
+ "\n",
+ "#Result\n",
+ "print(' Information capacity of telephone is C = %.2f kbps ' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Information capacity of telephone is C = 33.89 kbps \n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.62, Page No 517"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "p1=4.0\n",
+ "m1=0.5\n",
+ "m2=0.5\n",
+ "m3=0.375\n",
+ "m4=0.375\n",
+ "m5=0.375\n",
+ "m6=0.375\n",
+ "\n",
+ "#Calculation\n",
+ "I1=p1*math.log(1/p1,2) \n",
+ "HX=m1*math.log(1/m1,2)+m2*math.log(1/m2,2)+m3*math.log(1/m3,2)+m4*math.log(1/m4,2)+m5*math.log(1/m5,2)+m6*math.log(1/m6,2) #EntroSy of source\n",
+ "\n",
+ "#Result\n",
+ "print(' Entropy of system H(X)=%.2f bits/symbol ' %HX)\n",
+ "print('Approximation error')\t"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Entropy of system H(X)=3.12 bits/symbol \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.65, Page No 519"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "S0=1/2.0\n",
+ "S1=1/4.0\n",
+ "S2=1/8.0\n",
+ "S3=1/8.0\n",
+ "n=1\n",
+ "\n",
+ "#Calculation\n",
+ "H=S0*math.log(1.0/S0,2)+S1*math.log(1.0/S1,2)+S2*math.log(1.0/S2,2)+S3*math.log(1.0/S3,2) #EntroSy of source\n",
+ "L=H*n\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print(' Code length =%.2f bits/messages ' %L)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Code length =1.75 bits/messages \n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.67, Page No 520"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find channel capacity and new bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=8*10**3\n",
+ "SNR=31.0\n",
+ "SNR2=61\n",
+ "\n",
+ "#Calculation\n",
+ "C=B*math.log(1+SNR,2) #Information capacity\n",
+ "B2=C/math.log(1+SNR2,2)\n",
+ "#Result\n",
+ "print(' Channel capacity is C = %.2f x 10^3 bits/sec ' %(C/1000))\n",
+ "print(' New Bandwidth is C = %.2f x kHz ' %(B2/1000))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Channel capacity is C = 40.00 x 10^3 bits/sec \n",
+ " New Bandwidth is C = 6.72 x kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 31
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/Chapter9.ipynb b/Digital_Communications/Chapter9.ipynb
new file mode 100755
index 00000000..c91e1583
--- /dev/null
+++ b/Digital_Communications/Chapter9.ipynb
@@ -0,0 +1,166 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater 9: ERROR CONTROL CODING<h1>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find detected errors,corrected errors\n",
+ "\n",
+ "#initialisation of variables\n",
+ "dmin=5.0\n",
+ "#(s+1)<= dmin number errors can be detected(s)\n",
+ " \n",
+ "#CALCULATIONS\n",
+ "s=dmin-1\n",
+ "\n",
+ "#RESULTS\n",
+ "print(' i)Number of detected errors s <= %.f ' %s)\n",
+ "#(2t+1)<=dmin number errors can be corrected(t)\n",
+ "t=(dmin-1)/2.0\n",
+ "print('ii) Number of corrected errors t<= %.f ' %t)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " i)Number of detected errors s <= 4 \n",
+ "ii) Number of corrected errors t<= 2 \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.17, Page No 569"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Determine all possible code vectors \n",
+ "\n",
+ "m3=1\n",
+ "m2=0\n",
+ "m1=1\n",
+ "m0=0\n",
+ "#M=Message Matrix\n",
+ "#G=Generator Matrix\n",
+ "G=[[1, 0, 1, 1, 0, 0, 0],[0, 1, 0, 1, 1, 0, 0],[0, 0, 1, 0, 1, 1, 0],[0, 0, 0, 1, 0, 1, 1]]\n",
+ "M=[[m3,m2,m1,m0]]\n",
+ "X = [[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0]]\n",
+ "\n",
+ "for i in range(len(G)):\n",
+ " # iterate through columns of PXd\n",
+ " for j in range(len(M[0])):\n",
+ " # iterate through rows of PYX\n",
+ " for k in range(len(M)):\n",
+ " X[i][j] += G[i][k] * M[k][j]\n",
+ "print('The required code word')\n",
+ "for r in range(0,7):\n",
+ " print(X[0][r])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The required code word\n",
+ "1\n",
+ "0\n",
+ "1\n",
+ "0\n",
+ "0\n",
+ "0\n",
+ "0\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.19, Page No 572"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Determine code word \n",
+ "m3=1\n",
+ "m2=0\n",
+ "m1=1\n",
+ "m0=0\n",
+ "#M=Message Matrix\n",
+ "#G=Generator Matrix\n",
+ "G=[[1, 0, 0, 0, 1, 0, 1],[0, 1, 0, 0, 1, 1, 1],[0, 0, 1, 0, 1, 1, 0],[0, 0, 0, 1, 0, 1, 1]]\n",
+ "M=[[m3,m2,m1,m0]]\n",
+ "X = [[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0]]\n",
+ "\n",
+ "\n",
+ "for i in range(len(G)):\n",
+ " # iterate through columns of PXd\n",
+ " for j in range(len(M[0])):\n",
+ " # iterate through rows of PYX\n",
+ " for k in range(len(M)):\n",
+ " X[i][j] += G[i][k] * M[k][j]\n",
+ "print('The required code word')\n",
+ "for r in range(0,7):\n",
+ " print(X[0][r] )\n",
+ " \n",
+ "\n",
+ "print('The code in the book is wrong')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The required code word\n",
+ "1\n",
+ "0\n",
+ "1\n",
+ "0\n",
+ "0\n",
+ "0\n",
+ "0\n",
+ "The code in the book is wrong\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo2.ipynb b/Digital_Communications/ChapterNo2.ipynb
new file mode 100755
index 00000000..f8cf6b90
--- /dev/null
+++ b/Digital_Communications/ChapterNo2.ipynb
@@ -0,0 +1,290 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1>Chapter no 2: SAMPLING THEORY AND PULSE MODULATION<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.1, page no 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#find Nquist Rate\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given \n",
+ "pi=3.14\n",
+ "w1=50*pi\n",
+ "w2=300*pi\n",
+ "w3=100*pi\n",
+ "#w=2*%pi*f\n",
+ "\n",
+ "#Calculation\n",
+ "f1=w1/(2*pi)\n",
+ "f2=w2/(2*pi)\n",
+ "f3=w3/(2*pi)\n",
+ "fm=f2 #fm = maximum frquency is present at the signal\n",
+ "\n",
+ "#Result\n",
+ "print('maximum frquency of the signal is = %.2f Hz' %f2)\n",
+ "fs=2*fm #Nyquist rate\n",
+ "print('Nquist Rate of Signal is = %.2f Hz' %fs)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "maximum frquency of the signal is = 150.00 Hz\n",
+ "Nquist Rate of Signal is = 300.00 Hz\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.2 , page no 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Nquist Rate and Nquist time interval\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "w1=5000*math.pi\n",
+ "w2=3000*math.pi;\n",
+ "f1=w1/(2*math.pi);\n",
+ "f2=w2/(2*math.pi);\n",
+ "\n",
+ "#Calculation\n",
+ "fm=f1 #fm = maximum frquency is present at the signal\n",
+ "fs=2*fm #Nyquist rate\n",
+ "Ts=1.0/(2.0*fm) #frequncy =1/time\n",
+ "Ts=Ts*(10**3)\n",
+ "\n",
+ "#Result\n",
+ "print('maximum frquency of the signal is = %.f Hz' %f1)\n",
+ "print('Nquist Rate of the given Signal is = %.f Hz' %fs)\n",
+ "print('Nquist Interval of the given signal is = %.1f m Sec' %Ts)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "maximum frquency of the signal is = 2500 Hz\n",
+ "Nquist Rate of the given Signal is = 5000 Hz\n",
+ "Nquist Interval of the given signal is = 0.2 m Sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.3, page no 51"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find Nquist Rate \n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "f=100.0 # Frequency component of continuous-time signal\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*f #Nyquist rate\n",
+ "\n",
+ "#Result\n",
+ "print('i) To avoid aliasing Nquist Rate is = %.f Hz' %fs)\n",
+ "print('ii) It is theoretical example ')\n",
+ "print('iii) It is theoretical example ')\n",
+ "print('iv) It is theoretical example ')\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) To avoid aliasing Nquist Rate is = 200 Hz\n",
+ "ii) It is theoretical example \n",
+ "iii) It is theoretical example \n",
+ "iv) It is theoretical example \n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.4, page no 52 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Nquist Rate of Continous signal\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "w1=50*math.pi\n",
+ "w2=300*math.pi\n",
+ "w3=100*math.pi\n",
+ "\n",
+ "#Calculation\n",
+ "f1=w1/(2*math.pi)\n",
+ "f2=w2/(2*math.pi)\n",
+ "f3=w3/(2*math.pi)\n",
+ "fmax=f2 #fmax = Highest frquency component of the message signal\n",
+ "fs=2*fmax #Nyquist rate\n",
+ "\n",
+ "#Result\n",
+ "print('Highest frquency component of the message signal will be fmax = %.f Hz' %fmax)\n",
+ "print('Nquist Rate of the given Signal is = %.f Hz' %fs)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Highest frquency component of the message signal will be fmax = 150 Hz\n",
+ "Nquist Rate of the given Signal is = 300 Hz\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h3>Example 2.7, page no 67 <h3>"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#find amplitude distortion at highest frquency\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "fs=9.5 #samplig frequncy\n",
+ "fmax=1 #maximum frequncy\n",
+ "t=0.2 #pulse width\n",
+ "\n",
+ "#Calculation\n",
+ "c=3*10**8\n",
+ "f=fmax\n",
+ "H1=t*(0.9933) #aperture effect at highest frequency, sinc(f*t)=0.9933 (given)\n",
+ "H1=H1*100\n",
+ "\n",
+ "#Result\n",
+ "print('|H(1)|=%.2f' %H1)\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "|H(1)|=19.87\n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.8, page no 74 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Calculate Transmission Bandwidth\n",
+ "\n",
+ "#Variable declaration\n",
+ "#given\n",
+ "fm=3.0*(10^3)\n",
+ "fs=8.0*(10^3) # sampling frequncy\n",
+ "\n",
+ "#Calculation\n",
+ "Ts=1.0/fs\n",
+ "t=0.1*Ts\n",
+ "BW=1.0/(2*t) #Bandwidth\n",
+ "BW=BW/(10^3)\n",
+ "\n",
+ "#Result\n",
+ "print('Transmission Bandwidth of PAM signal is kHz = %.f Khz ' %BW)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Transmission Bandwidth of PAM signal is kHz = 40 Khz \n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo3.ipynb b/Digital_Communications/ChapterNo3.ipynb
new file mode 100755
index 00000000..5b9ea469
--- /dev/null
+++ b/Digital_Communications/ChapterNo3.ipynb
@@ -0,0 +1,2238 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 3: WAVEFORM CODING TECHNIQUES<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3,1 Page No 110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print('This is a Theoretical example')\t"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "This is a theoretcal example\n"
+ ]
+ }
+ ],
+ "prompt_number": 104
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3,2,i, Page No 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "#find code word length\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512 #Quantization levels\n",
+ "#q=2^v\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log10(512)/math.log10(2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"The code word legth is = %.f bits\" %v)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The code word legth is = 9 bits\n"
+ ]
+ }
+ ],
+ "prompt_number": 105
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2.ii, Page No 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#find The transmission Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512.0 #Quantization levels\n",
+ "v=9.0\n",
+ "\n",
+ "#Calculation\n",
+ "bw=v*fm*10**-6\n",
+ "\n",
+ "#Result\n",
+ "print(\"The transmission Bandwidth is = %.1f MHz\" %bw)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The transmission Bandwidth is = 37.8 MHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 106
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2.iii, Page No 111 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find Final Bit rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512.0 #Quantization levels\n",
+ "v=9.0\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm\n",
+ "r=v*fs #signaling rate\n",
+ "\n",
+ "#Result\n",
+ "print(\"Final Bit rate =%.1f x 10^6 bits/sec\" %(r/(10**6)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final Bit rate =75.6 x 10^6 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 107
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2.iv, Page No 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find Output signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "bandwidth=4.2*10**6\n",
+ "fm=bandwidth\n",
+ "q=512 #Quantization levels\n",
+ "v=9.0\n",
+ "\n",
+ "#Calculation\n",
+ "sn=4.8+6*v #noise in dB\n",
+ "\n",
+ "\n",
+ "print(\"Output signal to noise ratio is = %.1f dB\" %sn)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal to noise ratio is = 58.8 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 108
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.3.i, Page No 112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find bits per sample\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fmax=4*10**3\n",
+ "xmax=3.8\n",
+ "snr=100\n",
+ "\n",
+ "#Calculation\n",
+ "P=30*10**-3\n",
+ "v=(math.log10(((snr*xmax**2)/(3*P)))/(2*math.log10(2)))\n",
+ "\n",
+ "#Result\n",
+ "print(\"Number of bits required per sample are = %.2f bits\" %v)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of bits required per sample are = 6.98 bits\n"
+ ]
+ }
+ ],
+ "prompt_number": 109
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.3.ii, Page No 168"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find Transmission Bandwith\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=4*10**3 #Bandwidth of PCM\n",
+ "xmax=3.8\n",
+ "snr=100 #Signal to Noise Ratio\n",
+ "outputs=30.0\n",
+ "v=7.0\n",
+ "\n",
+ "#Calculation\n",
+ "bw=outputs*v*fm \n",
+ "r=bw*2\n",
+ "bw=bw/10**3\n",
+ "\n",
+ "#Result\n",
+ "print('Transmission Bandwith R = %.f kHz' %bw)\n",
+ "r=r/1000\n",
+ "print('Signaling rate R = %.f bits/sec' %r)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Transmission Bandwith R = 840 kHz\n",
+ "Signaling rate R = 1680 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 110
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.4, Page No 112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#find sampling rate,number of bits,bit rate,bandwidht\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "emax=0.001\n",
+ "de=2*emax\n",
+ "fm=100.0\n",
+ "xmax=10.0\n",
+ "\n",
+ "#Calculation\n",
+ "q=(2*xmax)/de\n",
+ "fs=2*fm\n",
+ "v=(math.log10(q))/math.log10(2)\n",
+ "v=math.ceil(v)\n",
+ "r=v*fs\n",
+ "\n",
+ "#Result\n",
+ "print('1. sampling Frequncy = %.f Hz ' %fs) \n",
+ "print('2. No.of bits in PCM = %.f bits ' %v) \n",
+ "print('3. sampling rate = %.f bits per second ' %r)\n",
+ "r=r/2\n",
+ "print('4. Transmission Bandwidth = %.f Hz ' %r) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. sampling Frequncy = 200 Hz \n",
+ "2. No.of bits in PCM = 14 bits \n",
+ "3. sampling rate = 2800 bits per second \n",
+ "4. Transmission Bandwidth = 1400 Hz \n"
+ ]
+ }
+ ],
+ "prompt_number": 111
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.5, Page No 113 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Bandwidth,Sampling Rate\n",
+ "\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=3.4*10**3\n",
+ "N=24\n",
+ "r=1.5*10**6\n",
+ "encoder=8\n",
+ "\n",
+ "#Calculation\n",
+ "BW=N*fm\n",
+ "BW=BW/10**3\n",
+ "r1=r/N\n",
+ "fs=r1/encoder\n",
+ "\n",
+ "#Result\n",
+ "print(\"i. Channel Bandwith is = %.2f kHz\" %BW)\n",
+ "print(\"ii. Sampling frequency is = %.2f Hz or samples per second.\" %fs)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i. Channel Bandwith is = 81.60 kHz\n",
+ "ii. Sampling frequency is = 7812.50 Hz or samples per second.\n"
+ ]
+ }
+ ],
+ "prompt_number": 112
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.6, Page No 114 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find Signal Bandwidth,Noise Ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "v=7\n",
+ "r=50*10**6\n",
+ "\n",
+ "#Calculation\n",
+ "#fs=2*fm\n",
+ "fm=r/(2*v)\n",
+ "snr=1.8+(6*v);\n",
+ "fm=fm*10**-6\n",
+ "\n",
+ "#Result\n",
+ "print('i. Maximum message Bandwidth is = %.2f MHz ' %fm)\n",
+ "print('ii. signal to quantization niose ration = %.2f dB ' %snr)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i. Maximum message Bandwidth is = 3.57 MHz \n",
+ "ii. signal to quantization niose ration = 43.80 dB \n"
+ ]
+ }
+ ],
+ "prompt_number": 113
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.7, Page No 114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#find i)bits per sample,ii)transmission rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=3*10**3\n",
+ "q=16\n",
+ "\n",
+ "#Calculation\n",
+ "v=(math.log10(q))/math.log10(2)\n",
+ "\n",
+ "#Result\n",
+ "print('i) Bits in code word= %.f bits' %v)\n",
+ "fs=2*fm\n",
+ "r=v*fs\n",
+ "print('ii) it trasmission rate= %.f x 10^3 bits per second' %(r/(10**3)))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Bits in code word= 4 bits\n",
+ "ii) it trasmission rate= 24 x 10^3 bits per second\n"
+ ]
+ }
+ ],
+ "prompt_number": 114
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.8, Page No 115"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "fm=3.5*10**3\n",
+ "r=50*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm\n",
+ "rms=0.2\n",
+ "xmax=2\n",
+ "v=r/fs #signaling rate r=v*fs\n",
+ "v=math.ceil(v)\n",
+ "P=(rms**2)/1\n",
+ "SNR=((3*P*2**(2*v))/(xmax**2))\n",
+ "SN=10*math.log10(SNR)\n",
+ "SN=math.ceil(SN)\n",
+ "\n",
+ "#Result\n",
+ "print(\"signal to niose ratio =%.f dB\" %SN)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "signal to niose ratio =33 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 115
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.10, Page No 117 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find i)noise ratio ii)bits\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "Am=3.0\n",
+ "v=10.0\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=1.8+6*v #noise ratio \n",
+ "SN=40\n",
+ "v=(SN-1.8)/6\n",
+ "\n",
+ "#Result\n",
+ "print(\"i) Signal to Quantization noise ratio = %.1f dB\" %SNR)\n",
+ "print(\"ii) Bits required to get signal to niose ratio of 40dB = %.f \" %math.ceil(v))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Signal to Quantization noise ratio = 61.8 dB\n",
+ "ii) Bits required to get signal to niose ratio of 40dB = 7 \n"
+ ]
+ }
+ ],
+ "prompt_number": 116
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.11, Page No 117 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Maximum frequency\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#Given data\n",
+ "v=7\n",
+ "SNR=1.8+6*v\n",
+ "r=56*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "fs=r/v #r=v*fs signaling rate\n",
+ "fm=fs/2 #Nquset rate\n",
+ "\n",
+ "#Result\n",
+ "fm=fm/10**3\n",
+ "print(\"Maximum frequency is = %.f kHz\" %fm)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum frequency is = 4 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 117
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.14, Page No 129 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Maximum Amplitude\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3*10**3.0\n",
+ "\n",
+ "#Calculation\n",
+ "Nyquistrate=2*fm #Nyquistrate\n",
+ "fs=5*Nyquistrate #Samplingfrquency\n",
+ "Ts=1/fs #Sampling Interval\n",
+ "de=0.25 #step size\n",
+ "fm1=2*10**3.0\n",
+ "Am=de/(2*math.pi*fm1*Ts)\n",
+ "\n",
+ "#Result\n",
+ "print(\"Maximum Amplitude = %.4f Volts\" %Am)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum Amplitude = 0.5968 Volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 118
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.16, Page No 130"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find signaling rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs1=8*10**3.0\n",
+ "de=31.25*10**-3\n",
+ "q=64.0\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log(q,2)\n",
+ "r=v*fs1 #signaling rate\n",
+ "fm=3*10**3.0\n",
+ "A=1\n",
+ "fs2=(2*math.pi*fm*A)/(de)\n",
+ "\n",
+ "#Result\n",
+ "r=r*10**-3\n",
+ "print(\"Signaling rate of PCM is = %.f kHz\" %r)\n",
+ "fs2=fs2*10**-3\n",
+ "print(\"The signaling rate of DM is = %.2f kHz\" %fs2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signaling rate of PCM is = 48 kHz\n",
+ "The signaling rate of DM is = 603.19 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 119
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.17, Page No 131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64.0*10**3 #frequency\n",
+ "fm=2.0*10**3 #Sinosoidal input signal sample \n",
+ "fM=4.0*10**3 #bandwidth\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=(3*fs**3)/(8*math.pi**2*fm**2*fM) #Signal to noise ratio\n",
+ "SNRO=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print(\"Output signal to noise ratio = %.2f dB\" %SNRO)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal to noise ratio = 27.94 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 120
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.18, Page No 131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find signal to Quatization noise ratio \n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=8.0*10**3 #Sampling frequency\n",
+ "r=64.0*10**3 #Data Rate\n",
+ "N=8 #number of bits\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=(1.8+6*N) #signal to Quatization noise ratio\n",
+ "\n",
+ "#Result\n",
+ "print(\"Signal to Quatization noise ratio of PCM system is = %.f dB\" %SNR)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signal to Quatization noise ratio of PCM system is = 50 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 121
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.20, Page No 149"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find sampling rate,quantizing level\n",
+ "\n",
+ "#Variable Declaration\n",
+ "r=36000\n",
+ "fm=3.2*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm #Nquest rate\n",
+ "v=r/fs #r=v*fs signaling rate\n",
+ "v=math.floor(v)\n",
+ "q=2**v\n",
+ "fs1=r/v\n",
+ "\n",
+ "#Result\n",
+ "print(\"Quantizing level q = %.f \" %q)\n",
+ "fs1=fs1/1000\n",
+ "print(\"sampling rate fs = %.1f kHz \" %fs1)\n",
+ "print(\"Number of binary digits = %.f \" %v)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizing level q = 32 \n",
+ "sampling rate fs = 7.2 kHz \n",
+ "Number of binary digits = 5 \n"
+ ]
+ }
+ ],
+ "prompt_number": 122
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.21, Page No 149"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find time duration of 1bit binary encoded signal\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=input(\"Enter the Nyquist rate of Signal fs(Hz)=\")\n",
+ "q=input(\"Enter the Quantization levels q =\")\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log(q,2) #binary pulses transmitted per second\n",
+ "t=1.0/(v*fs) #Nyquist interval\n",
+ "\n",
+ "#Result\n",
+ "print('Time duration of binary signal t = %.4f sec ' %t)\n",
+ "#output\n",
+ "#Enter the Nyquist rate fs(Hz)=3\n",
+ "#Enter the Quantization levels q =5\n",
+ "#time duration of 1bit binary signal \n",
+ "#t=0.1435589 sec"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Nyquist rate of Signal fs(Hz)=23\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Quantization levels q =34\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Time duration of binary signal t = 0.0085 sec \n"
+ ]
+ }
+ ],
+ "prompt_number": 123
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.23, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#find signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNR=40\n",
+ "SNRO=10**(SNR/10)\n",
+ "\n",
+ "#SNR=3(q**2)/2, Signal to Quantization noise ratio\n",
+ "\n",
+ "#Calculation\n",
+ "q=math.sqrt((2*SNRO)/3)\n",
+ "q=math.ceil(q)\n",
+ "v=math.log(q,2) #q=2**v Quantization levels\n",
+ "v=math.ceil(v)\n",
+ "snr=1.76+6.02*v #output Signal to Quantization noise ratio\n",
+ "\n",
+ "#Result\n",
+ "print(\"Output Signal to Quantization noise ratio = %.1f dB\" %snr)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output Signal to Quantization noise ratio = 43.9 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 124
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.24.i, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Quantizing levels,minimum number of bits per sample\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNRO=30.0\n",
+ "fmin=300.0\n",
+ "fmax=3300.0\n",
+ "fs=80000.0\n",
+ "\n",
+ "#Calculation\n",
+ "#SNRO=1.76+20log10(q)\n",
+ "q=10**((SNRO-1.76)/20)\n",
+ "q=math.ceil(q)\n",
+ "v=math.log(q,2)\n",
+ "\n",
+ "#Result\n",
+ "print('Quantizing levels required is =%.f' %q)\n",
+ "print('minimum number of bits per sample are=%.1f that is approximately 5' %v)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizing levels required is =26\n",
+ "minimum number of bits per sample are=4.7 that is approximately 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 125
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.24.ii, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find minimum required bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNRO=30.0 #Signal to quantisizing noise ratio\n",
+ "fmin=300.0 #min frequency band\n",
+ "fmax=3300.0 #max frequency band\n",
+ "fs=8000.0 #Sampling rate\n",
+ "v=5.0 #Minimum number of bits per sample\n",
+ "\n",
+ "#Calculation\n",
+ "fPCM=(v*fs)/2\n",
+ "fPCM=fPCM/1000\n",
+ "\n",
+ "#Result\n",
+ "print('minimum required bandwidth =%.f kHz' %fPCM)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "minimum required bandwidth =20 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 126
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.24.iii, Page No 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Quantizing levels,minimum number of bits per sample and bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNRO=30.0 #Signal to quantisizing noise ratio\n",
+ "fmin=300.0 #min frequency band\n",
+ "fmax=3300.0 #max frequency band\n",
+ "fs=8000.0 #Sampling rate\n",
+ "\n",
+ "#Calculation\n",
+ "q=10**((SNRO+10.1)/20)\n",
+ "q=math.ceil(q)\n",
+ "v=math.log(q,2)\n",
+ "v=math.ceil(v)\n",
+ "\n",
+ "#Result\n",
+ "print('Quantizing levels need is =%.f' %q)\n",
+ "print('minimum number of bits per sample is =%.f' %v)\n",
+ "fPCM=(v*fs)/2\n",
+ "fPCM=fPCM/1000\n",
+ "print('minimum required bandwidth =%.f Khz' %fPCM)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizing levels need is =102\n",
+ "minimum number of bits per sample is =7\n",
+ "minimum required bandwidth =28 Khz\n"
+ ]
+ }
+ ],
+ "prompt_number": 127
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.27, Page No 152"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#determine the Maximum Amplitude,\n",
+ "\n",
+ "#Variable Declaration\n",
+ "de=250*10**-3\n",
+ "wm=2*math.pi*1000 \n",
+ "fs=3*10**3\n",
+ "Ts=1/fs\n",
+ "\n",
+ "#Calculation\n",
+ "Amax=(de*3*fs*2)/(wm) #Amplitude\n",
+ "SNR=(3.0*((3*6*(10**3))**3))/((8*(math.pi**2)*(10**3)**3))\n",
+ "\n",
+ "#Result\n",
+ "print('Maximum Amplitude= %.1f mV' %(Amax*(10**2)))\n",
+ "print('Signal to noise ratio = %.2f dB' %(10*math.log10(SNR)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum Amplitude= 71.6 mV\n",
+ "Signal to noise ratio = 23.46 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 128
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.29, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of bits per sample\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SNR=20\n",
+ "averagepower=30*10**-3\n",
+ "SNRO=10**(SNR/10)\n",
+ "A=3.8\n",
+ "\n",
+ "#SNRO=average signal power/Quatizing power\n",
+ "#de=(2*A)/L\n",
+ "\n",
+ "#Calculation\n",
+ "L=math.sqrt((SNRO*A**2)/(3*averagepower))\n",
+ "n=math.log(L,2)\n",
+ "n=math.ceil(n)\n",
+ "\n",
+ "#Result\n",
+ "print('Bits required per sample =%.f' %n)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bits required per sample =7\n"
+ ]
+ }
+ ],
+ "prompt_number": 129
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.30.i, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Normalized power for quantization noise\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3.0*10.0**3\n",
+ "v=8.0\n",
+ "VH=5.0\n",
+ "VL=-5.0\n",
+ "q=2**v\n",
+ "\n",
+ "#Calculation\n",
+ "de=(VH-VL)/q\n",
+ "Nq=de**2/12.0 #quantization noise\n",
+ "\n",
+ "#Result\n",
+ "print('Normalized power for quantization noise =%.2f x 10^-6 W' %(Nq*(10**6)))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Normalized power for quantization noise =127.16 x 10^-6 W\n"
+ ]
+ }
+ ],
+ "prompt_number": 130
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.30.ii, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find bit transmission rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3*10.0**3\n",
+ "v=8.0\n",
+ "VH=5.0\n",
+ "VL=-5\n",
+ "q=2**v\n",
+ "\n",
+ "#Calculation\n",
+ "fs=2*fm #Nyquist rate\n",
+ "r=8*fs/1000\n",
+ "\n",
+ "#Result\n",
+ "print('bit transmission rate %.f K bits/s' %r)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "bit transmission rate 48 K bits/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 131
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.30.iii, Page No 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Signal to quantization noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "Nq=127.15*10**-6\n",
+ "Meansignal=2\n",
+ "\n",
+ "#Calculation\n",
+ "P=Meansignal/1\n",
+ "SNR=P/Nq\n",
+ "SNRq=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print('Signal to quantization noise ratio %.2f dB ' %SNRq)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signal to quantization noise ratio 41.97 dB \n"
+ ]
+ }
+ ],
+ "prompt_number": 132
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.31, Page No 154"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find i)SNR ii)output bit rate iii)no.of bits recorded\n",
+ "\n",
+ "#Variable Declaration\n",
+ "N=16.0\n",
+ "v=16.0\n",
+ "fs=44.1*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=1.76+6*N\n",
+ "bitrate=2*v*fs\n",
+ "outputbitrate=2*bitrate*10**-6 #including addtional 100% over head\n",
+ "CD=outputbitrate*3600*10**-3\n",
+ "\n",
+ "#Result\n",
+ "print('i)Out put signal noise ratio =%.2f dB' %SNR)\n",
+ "print('ii)output bit rate =%.3f Mbits/sec' %outputbitrate)\n",
+ "print('iii)no.of bits recorded in CD =%.2f gigabits' %CD)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)Out put signal noise ratio =97.76 dB\n",
+ "ii)output bit rate =2.822 Mbits/sec\n",
+ "iii)no.of bits recorded in CD =10.16 gigabits\n"
+ ]
+ }
+ ],
+ "prompt_number": 133
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.32, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find output SNR\n",
+ "#Variable Declaration\n",
+ "fm=1*10.0**3\n",
+ "fs=32*10**3\n",
+ "\n",
+ "#Calculation\n",
+ "FM=4*10**3 #Bandwidth\n",
+ "SNR=(3*fs**3)/(8*math.pi**2*fm**2*FM) #SNR\n",
+ "SNRO=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print('Output signal to noise ratio %.2f dB' %SNRO)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal to noise ratio 24.93 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 134
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.33.i, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step size\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64000.0 #samples/sec\n",
+ "Amax=1.0 #Maximum signal amplitude\n",
+ "fm=3500.0 #Sample Rate\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*Amax)/fs*1000\n",
+ "\n",
+ "#Result\n",
+ "print('Step Size %.2f mV ' %de)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Step Size 343.61 mV \n"
+ ]
+ }
+ ],
+ "prompt_number": 135
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.33ii, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Quantizatio noise power \n",
+ "#Variable Declaration\n",
+ "fs=64000.0 #sample Rate\n",
+ "Amax=1.0 #Maximum signal Amplitude\n",
+ "fm=3500.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=343.6117*10**-3 #step size\n",
+ "Nq=de**2/3.0 #Quantizatio noise power\n",
+ "Nqd=Nq*(fm/fs)*1000\n",
+ "\n",
+ "#Result\n",
+ "print('Quantizatio noise power %.3f mW' %Nqd)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quantizatio noise power 2.152 mW\n"
+ ]
+ }
+ ],
+ "prompt_number": 136
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.33iii, Page No 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find SNR\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64000.0\n",
+ "Amax=1.0\n",
+ "fm=3500.0\n",
+ "Nqd=2.1522995*10**-3\n",
+ "\n",
+ "#Calculation\n",
+ "So=Amax**2/2\n",
+ "SNR=So/Nqd\n",
+ "SNRO=10*math.log10(SNR)\n",
+ "\n",
+ "#Result\n",
+ "print('Output signal noise ratio dB %.3f dB' %SNRO)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output signal noise ratio dB 23.661 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 137
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.34, Page No 156"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Assuming signal is sampled at the rate 20% above Nyquist rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=4.5*10**6\n",
+ "q=1024.0\n",
+ "\n",
+ "#Calculation\n",
+ "fs=1.2*2*fm #20% above Nyquist rate\n",
+ "v=math.log(q,2)\n",
+ "r=v*fs/10**6\n",
+ "\n",
+ "#Result\n",
+ "print('no.of bits/sec = %.f M bit/sec' %r)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "no.of bits/sec = 108 M bit/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 138
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.35, Page No 156"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume bandwidth of the singal is 4kHz\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=32000.0\n",
+ "A=2.0\n",
+ "fm=4000.0\n",
+ "BW=4000.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*A)/fs\n",
+ "Nq=de**2/3\n",
+ "SNR=(3*fs**3)/(8*math.pi**2*fm**2*BW)\n",
+ "\n",
+ "#Result\n",
+ "print('i)step size = %.3f M Volt' %de)\n",
+ "print('ii)noise power = %.3f W' %Nq)\n",
+ "print('iii)SNR= = %.3f ' %SNR)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)step size = 1.571 M Volt\n",
+ "ii)noise power = 0.822 W\n",
+ "iii)SNR= = 19.454 \n"
+ ]
+ }
+ ],
+ "prompt_number": 139
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.36, Page No 157"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assuming signal is sampled at the rate 20% above Nyquist rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=15*10**3\n",
+ "fs=1.2*2*fm\n",
+ "q=65536\n",
+ "\n",
+ "#Calculation\n",
+ "v=math.log(q,2)\n",
+ "r=v*fs/1000\n",
+ "BW=r/2\n",
+ "\n",
+ "#Result\n",
+ "print('i)signaling rate,= %.f K bits/sec ' %r)\n",
+ "print('ii)bandwidth BW min = %.f kHz ' %BW)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)signaling rate,= 576 K bits/sec \n",
+ "ii)bandwidth BW min = 288 kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 140
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.37, Page No 157"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step size,noise power\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=64*10**3\n",
+ "fm=3500.0\n",
+ "A=1.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*A)/fs #step size\n",
+ "Nq=(de**2/3)*(fm/fs) #Granular noise power\n",
+ "\n",
+ "#Result\n",
+ "print('i)step size = %.3f Volts' %de)\n",
+ "print('ii)Nq= %.5f W' %Nq)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)step size = 0.344 Volts\n",
+ "ii)Nq= 0.00215 W\n"
+ ]
+ }
+ ],
+ "prompt_number": 141
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.40, Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step Nr,Transmission Bandwidth, SNR\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fs=4 #kHz\n",
+ "N=12\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=2*fs #Nyquest rate\n",
+ "Bt=1.0/2*N*fs #Transmission Bandwidth\n",
+ "SNR=1.8+(6*N) \n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print('i)Nyquest rate = %.1f kHz' %Nr)\n",
+ "print('ii)Transmission Bandwidth = %.1f kHz' %Bt)\n",
+ "print('iii)SNR = %.1f dB' %SNR)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)Nyquest rate = 8.0 kHz\n",
+ "ii)Transmission Bandwidth = 24.0 kHz\n",
+ "iii)SNR = 73.8 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 142
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.41, Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find step size,noise power\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=3.5*10**3\n",
+ "fs=64*10**3\n",
+ "A=2.0\n",
+ "\n",
+ "#Calculation\n",
+ "de=(2*math.pi*fm*A)/fs #step size\n",
+ "Nq=(de**2/3)*(fm/fs) #Granular noise power\n",
+ "\n",
+ "#Result\n",
+ "print('i)step size = %.3f Volts' %de)\n",
+ "print('ii)Nq= %.1f X 10^-3 W' %(Nq*10**3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i)step size = 0.687 Volts\n",
+ "ii)Nq= 8.6 X 10^-3 W\n"
+ ]
+ }
+ ],
+ "prompt_number": 143
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.42, Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Bit rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=4.5 * 10**6 #khz\n",
+ "Nr = 2 * W #Nyquist Rate\n",
+ "Q = 1024\n",
+ "fs=10.8\n",
+ "\n",
+ "#Calculation\n",
+ "N = math.log(Q,2) #number of binay pulse per word\n",
+ "Br= N*fs #Bit rate\n",
+ "Bw= 1.0/2*Br #Bandwidth\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of binay pulse per word = %.1f k bits/sec' %N)\n",
+ "print('ii) Bit rate = %.1f k bits/sec' %Br)\n",
+ "print('iii)Bandwidth= %.1f X 10^-3 kHz' %Bw)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of binay pulse per word = 10.0 k bits/sec\n",
+ "ii) Bit rate = 108.0 k bits/sec\n",
+ "iii)Bandwidth= 54.0 X 10^-3 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 144
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.43, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Bit rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=15 #khz\n",
+ "Nr = 2*W #Nyquist Rate\n",
+ "Q = 65.53\n",
+ "fs=44.1 # Sampling rate kHz\n",
+ "N=16\n",
+ "\n",
+ "#Calculation\n",
+ "Br= N*fs #Bit rate\n",
+ "Bw= 1.0/2*Br #Bandwidth\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of binay pulse per word = %.3f bits' %N)\n",
+ "print('ii) Bit rate = %.1f k bits/sec' %Br)\n",
+ "print('iii)Bandwidth= %.1f kHz' %Bw)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of binay pulse per word = 16.000 bits\n",
+ "ii) Bit rate = 705.6 k bits/sec\n",
+ "iii)Bandwidth= 352.8 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 145
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.44, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Number of binay pulse per word\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=3.3 #khz\n",
+ "fm = 1*10**3 #kHz\n",
+ "de = 250 #mV\n",
+ "fs=19.8 # Sampling rate kHz\n",
+ "\n",
+ "#Calculation\n",
+ "A=(de*fs)/(2*math.pi*fm)\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of binay pulse per word = %.3f' %A)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of binay pulse per word = 0.788\n"
+ ]
+ }
+ ],
+ "prompt_number": 146
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.45, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Signaling rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=3.3 #khz\n",
+ "fm = 3300 #Hz\n",
+ "Snq = 40 #dB\n",
+ "fs= 8000 # Samples/sec\n",
+ "\n",
+ "#Calculation \n",
+ "N=math.ceil((Snq-4.8)/6) # Number of bits per word\n",
+ "Q=2**N #\n",
+ "r=N*fs #Signaling rate k bits/sec\n",
+ "Bw=1.0/2*r\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of bits per word = %.1f' %N)\n",
+ "print('ii) Signaling rate rate = %.1f k bits/sec' %(r/10**3))\n",
+ "print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of bits per word = 6.0\n",
+ "ii) Signaling rate rate = 48.0 k bits/sec\n",
+ "iii)Bandwidth= 24.0 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 147
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.46, Page No 161"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find the maximun frequency with 1 volt amplitude\n",
+ "\n",
+ "#Variable Declaration\n",
+ "de=256*10**-3 #V\n",
+ "Ts = 10*10**-6 #kHz\n",
+ "fm = 10 #kHz\n",
+ "fs= 100 # kHz\n",
+ "A=1 #V\n",
+ "\n",
+ "#Calculation \n",
+ "wm=(de/A*Ts)*10**7\n",
+ "\n",
+ "#Result\n",
+ "print('i) maximun frequency = %.1f X 10^3 rad/sec' %wm)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) maximun frequency = 25.6 X 10^3 rad/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 148
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.47, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find the Signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "Q=256 \n",
+ "m=255\n",
+ "\n",
+ "#Calculation \n",
+ "SNR=(3*Q**2)/(math.log((1+m),math.e))**2 #dB\n",
+ "Gc=m/(math.log(1+m)) #Companding gain\n",
+ "Gc=20*math.log(Gc,10)\n",
+ "\n",
+ "#Result\n",
+ "print('i) The Signal to noise ratio= %.1f dB' %SNR)\n",
+ "print('ii) The Companding gain = %.1f dB' %Gc)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) The Signal to noise ratio= 6394.0 dB\n",
+ "ii) The Companding gain = 33.3 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 149
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.48, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of binay pulse per word, Signaling rate, Bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=15*10**3 #kHz\n",
+ "Q=200\n",
+ "fs=2*fm\n",
+ "\n",
+ "#Calculation \n",
+ "N=math.ceil(math.log(Q,2))\n",
+ "tr=N*fs #Transmission rate kbps\n",
+ "Bw=1.0/2*tr\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of bits per Samples = %.1f' %N)\n",
+ "print('ii) Signaling rate = %.1f k bits/sec' %(tr/10**3))\n",
+ "print('iii)Bandwidth= %.1f kHz' %(Bw/10**3))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of bits per Samples = 8.0\n",
+ "ii) Signaling rate = 240.0 k bits/sec\n",
+ "iii)Bandwidth= 120.0 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 150
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.49, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find number of quantization level\n",
+ "\n",
+ "#Variable Declaration\n",
+ "tr=36.0 #kbps\n",
+ "fm=3.4 #kHz\n",
+ "fs=8\n",
+ "\n",
+ "#Calculation \n",
+ "N=math.ceil(tr/fs)\n",
+ "Q=2**N\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print('i) number of quantization level = %.1f' %Q)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) number of quantization level = 32.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 151
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.50, Page No 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find delta modulation\n",
+ "\n",
+ "#Variable Declaration\n",
+ "A=1 #V\n",
+ "fm=3.4 #kHz\n",
+ "fs=20\n",
+ "\n",
+ "#Calculation \n",
+ "de=1*2*math.pi*(fm/fs)\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print('i) delta modulation = %.2f V' %de)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) delta modulation = 1.07 V\n"
+ ]
+ }
+ ],
+ "prompt_number": 152
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.51, Page No 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=3.5 #kHz\n",
+ "r=50.0 #kbps\n",
+ "Vpp=4 #V\n",
+ "fs=8\n",
+ "\n",
+ "#Calculation \n",
+ "N=r/fs\n",
+ "SNR=4.8+(6.8*N)\n",
+ "\n",
+ "#Result\n",
+ "print('i) Signal to noise ratio = %.2f V' %SNR)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Signal to noise ratio = 47.30 V\n"
+ ]
+ }
+ ],
+ "prompt_number": 153
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.52, Page No 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Signal to noise ratio\n",
+ "\n",
+ "#Variable Declaration\n",
+ "W=1 #MHz\n",
+ "fs1=3 #MHz\n",
+ "fs2=2.4 #MHz\n",
+ "Q=256\n",
+ "m=255\n",
+ "\n",
+ "#Calculation \n",
+ "SNR=((3*Q**2)/(math.log((1+m),math.e))**2)\n",
+ "SNR1=63095.73 #SNR=38+10\n",
+ "Q1=math.sqrt((SNR1*((math.log(256,math.e))**2))/3)\n",
+ "N1=math.ceil(math.log(Q1,2))\n",
+ "r=N1*fs2\n",
+ "Bw=1.0/2*r\n",
+ "\n",
+ "#Result\n",
+ "print('i) Number of bits/word = %.2f ' %N1)\n",
+ "print('ii) Bit rate = %.1f Mb/s' %r)\n",
+ "print('iii) Bandwidth = %.1f Mb/s' %Bw)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Number of bits/word = 10.00 \n",
+ "ii) Bit rate = 24.0 Mb/s\n",
+ "iii) Bandwidth = 12.0 Mb/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 154
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo4.ipynb b/Digital_Communications/ChapterNo4.ipynb
new file mode 100755
index 00000000..547a969e
--- /dev/null
+++ b/Digital_Communications/ChapterNo4.ipynb
@@ -0,0 +1,273 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 4: DIGITAL MULTIPLEXERS<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.4, page no 190 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Caption: Sampling Rate\n",
+ "\n",
+ "#initialisation of variables\n",
+ "f1=4.0*10**3\n",
+ "f2=4.5*10**3\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "fsmin=(2*f2)/1000\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\" Sampling rate =%.2f kHz\" %fsmin)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Sampling rate =9.00 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.5, Page No 190 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Caption: Nyquest rate,Signaling rate,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "f1=3000.0\n",
+ "f4=1000.0\n",
+ "f2=1000.0\n",
+ "f3=1000.0\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "#Nyquest rate\n",
+ "nq1=2*f1\n",
+ "nq2=2*f2\n",
+ "nq3=2*f3\n",
+ "nq4=2*f4\n",
+ "\n",
+ "#RESULTS\n",
+ "print('i. Nyquest rate of x1 =%.2fkHz' %nq1)\n",
+ "print('ii. Nyquest rate of x2 =%.2fkHz' %nq2)\n",
+ "print('iii. Nyquest rate of x3 =%.2fkHz' %nq3)\n",
+ "print('iv. Nyquest rate of x4 =%.2fkHz' %nq4)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i. Nyquest rate of x1 =6000.00kHz\n",
+ "ii. Nyquest rate of x2 =2000.00kHz\n",
+ "iii. Nyquest rate of x3 =2000.00kHz\n",
+ "iv. Nyquest rate of x4 =2000.00kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.6, Page No 190 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find The spacing between two successive pules\n",
+ "\n",
+ "#initialisation of variables\n",
+ "samplingrate=8000.0\n",
+ "totalsignals=24+1\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "t=1/samplingrate\n",
+ "T=t/totalsignals\n",
+ "T=T*10**6 #time is now u sec\n",
+ "space=T-1\n",
+ "\n",
+ "#RESULTS\n",
+ "print('The spacing between two successive pules %.f u sec' %space)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The spacing between two successive pules 4 u sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.7, Page No 191"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find signaling rate ,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "N=6.0\n",
+ "fm=5000.0\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "r=2*fm #sampling rate\n",
+ "sr=N*r #signalingrate\n",
+ "BW=N*fm #Bandwith\n",
+ "sr=sr/1000\n",
+ "BW=BW/1000\n",
+ "\n",
+ "#RESULTS\n",
+ "print('Signaling rate %.f K bits/sec' %sr)\n",
+ "print('Bandwith to avoid the cross talk in TDM is %.f kHz' %BW)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Signaling rate 60 K bits/sec\n",
+ "Bandwith to avoid the cross talk in TDM is 30 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.9, Page No 198"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find signaling rate ,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "N=4.0\n",
+ "x=24 #bits/frame\n",
+ "D=1152\n",
+ "s=1.0/3\n",
+ "r=1.544*10**6\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "r0=N*r*((D+x)/(D-s*N))\n",
+ "\n",
+ "#RESULTS\n",
+ "print('Output bit rate %.2f MB/sec' %(r0/(10**6)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Output bit rate 6.31 MB/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.10, Page No 198"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find signaling rate ,bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "N=24.0\n",
+ "x=72.0 #bits\n",
+ "D=192 #message and stuff bits\n",
+ "s=1.0/3\n",
+ "r=64 #kb/sec\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "r0=N*r*((D+x)/(D-s*N))\n",
+ "r1=((N*r)/r0)*100\n",
+ "\n",
+ "#RESULTS\n",
+ "print('i) Output bit rate %.2f MB/sec' %(r0/(10**3)))\n",
+ "print('iI) Throughput efficiency is = %.2f percent' %r1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) Output bit rate 2.20 MB/sec\n",
+ "iI) Throughput efficiency is = 69.70 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo5.ipynb b/Digital_Communications/ChapterNo5.ipynb
new file mode 100755
index 00000000..b36df857
--- /dev/null
+++ b/Digital_Communications/ChapterNo5.ipynb
@@ -0,0 +1,105 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 5: DIGTIAL BASEBAND TRANSMISSION<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.12, Page No 249 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find The roll of factor alpha\n",
+ "\n",
+ "#initialisation of variables\n",
+ "datarate=0.1*10**6\n",
+ "fB=75000.0 #bandwidth\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Tb=1/datarate\n",
+ "alpha=2*fB*Tb-1\n",
+ "\n",
+ "#RESULTS\n",
+ "print('The roll out factor alpha = = %.1f ' %alpha)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The roll out factor alpha = = 0.5 \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.13, Page No 249"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find The Transmission bandwidth\n",
+ "\n",
+ "#initialisation of variables\n",
+ "q=128.0\n",
+ "alpha=0.2\n",
+ "n=math.log(q,2)\n",
+ "fm=2000.0\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Nq=2*fm\n",
+ "fs=1.25*Nq\n",
+ "N=8.0\n",
+ "total=N*fs\n",
+ "bitrate=7*total\n",
+ "fB=((1+alpha)*bitrate)/2\n",
+ "fB=fB/1000\n",
+ "#RESULTS\n",
+ "print('The minimum transmission Bandwidth required = %.f kHz' %fB)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The minimum transmission Bandwidth required = 168 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo6.ipynb b/Digital_Communications/ChapterNo6.ipynb
new file mode 100755
index 00000000..83113b9c
--- /dev/null
+++ b/Digital_Communications/ChapterNo6.ipynb
@@ -0,0 +1,158 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 6: DIGITAL MODULATION TECHNIQUES<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.5, Page No 327"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "#Symbol rate of transmission and bandwidth \n",
+ "\n",
+ "#initialisation of variables\n",
+ "fb=1.0 #MHz\n",
+ "Tb=1/fb #bit period ms\n",
+ "N=4\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Ts1=Tb\n",
+ "Bw1=2*fb\n",
+ "Ts2=Tb*2\n",
+ "Tr2=(1.0/2)*1000 #Symbols/sec\n",
+ "Bw2=1/Tb\n",
+ "Ts3=N*Tb\n",
+ "Tr3=(1.0/4)*1000\n",
+ "Bw3=(2.0*fb)/N\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"In BPSK\")\n",
+ "print(\"The symbol rate of transmission is = %.f X 10^6 symbol/sec \" %Ts1)\n",
+ "print(\"The Bandwidth is = %.f MHz \" %Bw1)\n",
+ "print(\"In QPSK\")\n",
+ "print(\"The symbol rate of transmission is = %.f X 10^3 symbol/sec \" %Tr2)\n",
+ "print(\"The Bandwidth is = %.f MHz \" %Bw2)\n",
+ "print(\"In 16-ary PSK\")\n",
+ "print(\"The symbol rate of transmission is = %.f X 10^3 symbol/sec \" %Tr3)\n",
+ "print(\"The Bandwidth is = %.f kHz \" %(Bw3*1000))\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "In BPSK\n",
+ "The symbol rate of transmission is = 1 X 10^6 symbol/sec \n",
+ "The Bandwidth is = 2 MHz \n",
+ "In QPSK\n",
+ "The symbol rate of transmission is = 500 X 10^3 symbol/sec \n",
+ "The Bandwidth is = 1 MHz \n",
+ "In 16-ary PSK\n",
+ "The symbol rate of transmission is = 250 X 10^3 symbol/sec \n",
+ "The Bandwidth is = 500 kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.6, Page No 328"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "fb=90 #MHz\n",
+ "Bw=20 #Mb/s\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "N=(2*fb)/Bw\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"Number of bits required = %.f \" %N)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of bits required = 9 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.12, Page No 357"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Tb=0.1 #msec\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "fb=1/Tb\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"Transmission bandwidth = %.f kHz\" %fb)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Transmission bandwidth = 10 kHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo7.ipynb b/Digital_Communications/ChapterNo7.ipynb
new file mode 100755
index 00000000..9d58a722
--- /dev/null
+++ b/Digital_Communications/ChapterNo7.ipynb
@@ -0,0 +1,431 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 7: PERFORMANCE ANALYSIS OF DIGITAL COMMUNICATION SYSTEMS<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.15, Page No 414"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "#initialisation of variables\n",
+ "T=1.0*10**-6 #ms\n",
+ "A=10.0*10**-3\n",
+ "N=1*10**-11\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Eb=((A**2)*T)/2.0\n",
+ "Epb=math.sqrt(Eb/N)\n",
+ "Pb=(1.0/2)*math.erfc(Epb)*(1.0/4)\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"Bit error probability = %.2f X 10^-4 \" %(Pb*(10**4)))\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bit error probability = 1.96 X 10^-4 \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.16, Page No 420"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Br=25*10**6 #bits/sec\n",
+ "N=2*10**-20 #Power spectral density of noise\n",
+ "A=1.0*10**-6\n",
+ "Ps=1*10**-12 # Normalized power\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Tb=1.0/Br\n",
+ "Ps=(A**2)/2.0\n",
+ "Pe=1.0/2*(math.erfc((0.6*Ps*Tb)/N))\n",
+ "#RESULTS\n",
+ "print(\"Average probability of bit error is Pe= %.2f X 10^-4 \" %(Pe*10))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Average probability of bit error is Pe= 1.98 X 10^-4 \n"
+ ]
+ }
+ ],
+ "prompt_number": 45
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.17, Page No 423"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find probability of error\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=2.0\n",
+ "N0=2.0*10**-4 #power sepctral density\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Tmin=(6.76*N0)/4\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The min time for which the signal should be extended is Tmin= %.3f X 10^-3 msec \" %(Tmin*10**3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The min time for which the signal should be extended is Tmin= 0.338 X 10^-3 msec \n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.20, Page No 428"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#The average carrier\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Pe=10**-4\n",
+ "N0=2*10**10\n",
+ "T=1.0/10**6\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "E=6.76*N0\n",
+ "P=E/T\n",
+ "Eb=8.5171*N0\n",
+ "P2=Eb/T\n",
+ "\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The average carrier = %.3f X 10^-3 mW \" %(P2/10**17))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The average carrier = 1.703 X 10^-3 mW \n"
+ ]
+ }
+ ],
+ "prompt_number": 47
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.21, Page No 430"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#The average carrier\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=0.2*10**-3 #V\n",
+ "T=2*10**-6\n",
+ "N0=2*10**-15\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Pe=(math.sqrt((A**2*T)/4*N0))\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The average carrier = %.3f X 10^-4 mW \" %(Pe*10**15))\n",
+ "print(\"Approximation error\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The average carrier = 6.325 X 10^-4 mW \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 48
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.29, Page No 447"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=1.0\n",
+ "N0=2.0*10**-5 #power sepctral density\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "T=((3.71**2)*2*N0)/(A**2)\n",
+ "Br=1/T\n",
+ "#Results\n",
+ "print(\"Bit rate Br= %.2f k bits/sec\" %(Br/(10**3)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bit rate Br= 1.82 k bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 49
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.31, Page No 448"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Pe=10.0**-4 #probability of error of PSK\n",
+ "N0=2.0*10**-10\n",
+ "Br=10**6 #Bit Rate\n",
+ "\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "T=1.0/Br\n",
+ "E=N0*6.76\n",
+ "P=E/T\n",
+ "Eb=8.5171*N0\n",
+ "Pb=Eb/T\n",
+ "#Results\n",
+ "print(\"i) PSK system The required carrier power = %.2f mW\" %(P*10**3))\n",
+ "print(\"ii) DPSK system The required carrier power = %.2f mW\" %(Pb*10**3))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) PSK system The required carrier power = 1.35 mW\n",
+ "ii) DPSK system The required carrier power = 1.70 mW\n"
+ ]
+ }
+ ],
+ "prompt_number": 50
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.32, Page No 450"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "A=0.2*10**-3 #V\n",
+ "T=2*10**-6 #Sec\n",
+ "N0=2*10**-15\n",
+ "\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "x=math.sqrt((A**2*T)/(4*N0))\n",
+ "Pe=(1.0/2)*math.erfc(x/math.sqrt(2.0))\n",
+ "\n",
+ "#Results\n",
+ "print(\"Probability of error = %.2f X 10^-4\" %(Pe*10**4))\n",
+ "#print(\"Channel Bandwidth = %.5f MHz\" %BW)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Probability of error = 7.83 X 10^-4\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.36, Page No 453"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Ap=1 #mV\n",
+ "En=192.3 #mV\n",
+ "Arms=707 #mV\n",
+ "\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Z=Arms/En\n",
+ "Pe=1.0/2*(math.erfc(math.sqrt(2)*(Z/math.sqrt(2))))\n",
+ "\n",
+ "#Results\n",
+ "print(\"Probability of error is %.7f \" %Pe)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Probability of error is 0.0000001 \n"
+ ]
+ }
+ ],
+ "prompt_number": 52
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.37, Page No 454"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#initialisation of variables\n",
+ "Br=2.08*10**-6 #Bit Rate\n",
+ "N0=2*10**-8\n",
+ "\n",
+ "#CALCULATIONS\n",
+ "Eb=(math.sqrt(3.3))/(5*10**7) #Eb=bit energy\n",
+ "Ps=Eb*Br\n",
+ "BW=2*Br #Bandwidth\n",
+ "Es=286.39*N0\n",
+ "Ps2=(Es*Br)/2\n",
+ "BW2=(2*Br)/4\n",
+ "\n",
+ "#Results\n",
+ "print(\"i) BPSK THe transmission bandwidth = %.2f MHz\" %(BW*10**6)) \n",
+ "print(\"ii) For 16 ary PSK THe transmission bandwidth = %.2f MHz\" %(BW2*10**6)) \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i) BPSK THe transmission bandwidth = 4.16 MHz\n",
+ "ii) For 16 ary PSK THe transmission bandwidth = 1.04 MHz\n"
+ ]
+ }
+ ],
+ "prompt_number": 53
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo8.ipynb b/Digital_Communications/ChapterNo8.ipynb
new file mode 100755
index 00000000..d34d983c
--- /dev/null
+++ b/Digital_Communications/ChapterNo8.ipynb
@@ -0,0 +1,1439 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 8: INFORMATION THEORY<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.1, Page No 464"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "#Find Information Content of Each Symbol\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/8.0\n",
+ "\n",
+ "#Calculation\n",
+ "#information content of each symbol\n",
+ "Ix1=math.log(1/px1,2)\n",
+ "Ix2=math.log(1/px2,2)\n",
+ "Ix3=math.log(1/px3,2)\n",
+ "Ix4=math.log(1/px4,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"Information Content tI(x1)= %.2f bit\" %Ix1)\n",
+ "print(\" tI(x2)= %.f bits\" %Ix2)\n",
+ "print(\" tI(x3)= %.f bits\" %Ix3)\n",
+ "print(\" tI(x4)= %.f bits\" %Ix4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Information Content tI(x1)= 1.00 bit\n",
+ " tI(x2)= 2 bits\n",
+ " tI(x3)= 3 bits\n",
+ " tI(x4)= 3 bits\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.2, Page No 464"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find amount of Information\n",
+ "#Variable Declaration\n",
+ "#Calculation\n",
+ "pxi=1/4.0\n",
+ "Ixi=(math.log10(1/pxi))/math.log10(2)\n",
+ "\n",
+ "#RESULTS\n",
+ "print(\"The amount of Information I(Xi)= %.f \" %Ixi)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The amount of Information I(Xi)= 2 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.3, Page No 464"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Amount of Information\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/2.0\n",
+ "\n",
+ "#Calculation\n",
+ "Ix1=math.log(1/px1,2) #entropy\n",
+ "Ix2=math.log(1/px2,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"The amount of Information I(X1)= %.f bit\" %Ix1)\n",
+ "print(\"The amount of Information I(X2)= %.f bit\" %Ix2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The amount of Information I(X1)= 1 bit\n",
+ "The amount of Information I(X2)= 1 bit\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.4, Page No 465"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Amount of Information \n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/4.0\n",
+ "px2=3/4.0\n",
+ "\n",
+ "#Calculation\n",
+ "Ix1=math.log(1/px1,2)\n",
+ "Ix2=math.log(1/px2,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\"The amount of Information I(X1)= %.f bit\" %Ix1)\n",
+ "print(\"The amount of Information I(X2)= %.2f bit\" %Ix2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The amount of Information I(X1)= 2 bit\n",
+ "The amount of Information I(X2)= 0.42 bit\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.9, Page No 468 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Entropy,Amount of information\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.4\n",
+ "px2=0.3\n",
+ "px3=0.2\n",
+ "px4=0.1\n",
+ "\n",
+ "#Calculation\n",
+ "HX=-px1*math.log(px1,2)-px2*math.log(px2,2)-px3*math.log(px3,2)-px4*math.log(px4,2)\n",
+ "Px1x2x1x3=px1*px2*px1*px3\n",
+ "Ix1x2x1x3=-math.log(Px1x2x1x3,2)\n",
+ "Px4x3x3x2=px4*px3*px3*px2\n",
+ "Ix4x3x3x2=-math.log(Px4x3x3x2,2)\n",
+ "\n",
+ "#Result\n",
+ "print(\" \\n Entropy H(X) = %.2f bits/symbol \" %HX)\n",
+ "print(\"The amount of Information I(x1x2x1x3)= %.2f bits/symbol\" %Ix1x2x1x3)\n",
+ "print(\" I(x4x3x3x2) = %.2f bits/symbol \" %Ix4x3x3x2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " \n",
+ " Entropy H(X) = 1.85 bits/symbol \n",
+ "The amount of Information I(x1x2x1x3)= 6.70 bits/symbol\n",
+ " I(x4x3x3x2) = 9.70 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.13, Page No 471"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Find information rate the telegraphic source\n",
+ "\n",
+ "#Variable Declaration\n",
+ "pdash=1/3.0\n",
+ "pdot=2/3.0\n",
+ "tdot=0.2\n",
+ "tdash=0.6\n",
+ "tspace=0.2\n",
+ "\n",
+ "#Calculation\n",
+ "HX=-pdash*math.log(pdash,2)-pdot*math.log(pdot,2)\n",
+ "Ts=pdot*tdot+pdash*tdash+tspace\n",
+ "r=1/Ts\n",
+ "R=r*HX\n",
+ "\n",
+ "#Result\n",
+ "print('Average rate of information R = %.2f bits/s' %R)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Average rate of information R = 1.72 bits/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.14, Page No 471"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find information rate of the source\n",
+ "\n",
+ "f=input('Enter the frequncy f=')\n",
+ "px1=1/8.0\n",
+ "px2=1/8.0\n",
+ "px3=3/8.0\n",
+ "px4=3/8.0\n",
+ "\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2) #entropy of the source\n",
+ "R=2*f*HX #r=2*f\n",
+ "print('information rate R= %.1f bits/sec ' %R) #f=signal bandwidth\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the frequncy f=34\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "information rate R= 123.2 bits/sec \n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.15, Page No 472"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find information rate of the source\n",
+ "#all symbols are equally likely\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/2.0\n",
+ "px3=1/2.0\n",
+ "px4=1/2.0\n",
+ "\n",
+ "#Calculation\n",
+ "f=input('Enter the frequncy of system fm(in Hz) =')\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)\n",
+ "\n",
+ "#Result\n",
+ "print('\\n Entropy H(X) =%.f bits/symbol ' %HX)\n",
+ "R=2*f*HX\n",
+ "print('information rate =%.f bits/sec' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the frequncy of system fm(in Hz) =45\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " Entropy H(X) =2 bits/symbol \n",
+ "information rate =180 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.16, Page No 473"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find source entropy ,information rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "#probability symbols\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/16.0\n",
+ "px5=1/16.0\n",
+ "Tb=10.0**-3\n",
+ "\n",
+ "#Calculation\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4)+px5*math.log(1/px5)\n",
+ "\n",
+ "#Result\n",
+ "print('1. source entropy H(X) = %.2f bits/symbol ' %HX) #source entropy\n",
+ "r=1.0/Tb\n",
+ "R=r*HX #information rate\n",
+ "print(' 2. Information rate R = %.2f bits/sec ' %R)\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. source entropy H(X) = 1.72 bits/symbol \n",
+ " 2. Information rate R = 1721.57 bits/sec \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.17, Page No 473"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume if there are 16 outcomes per second\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/16.0\n",
+ "px5=1/16.0\n",
+ "r=16.0\n",
+ "\n",
+ "#Calculation\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)+px5*math.log(1/px5,2)\n",
+ "\n",
+ "#Result\n",
+ "print('1. Entropy H(X) = %.2f bits/symbol ' %HX) #source entropy\n",
+ "\n",
+ "R=r*HX\n",
+ "print('2., Information rate R = %.f bits/sec' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. Entropy H(X) = 1.88 bits/symbol \n",
+ "2., Information rate R = 30 bits/sec\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.18, Page No 474"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#determine entropy ,information rate\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/4.0\n",
+ "px2=1/5.0\n",
+ "px3=1/5.0\n",
+ "px4=1/10.0\n",
+ "px5=1/10.0\n",
+ "px6=1/20.0\n",
+ "px7=1/20.0\n",
+ "px8=1/20.0\n",
+ "f=10*10**3.0\n",
+ "fs=10*2*10**3.0\n",
+ "\n",
+ "#Calculation\n",
+ "#entropy\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)+px5*math.log(1/px5,2)+px6*math.log(1/px6,2)+px7*math.log(1/px7,2)+px8*math.log(1/px8,2) \n",
+ "\n",
+ "#Result\n",
+ "print('bits/message H(X) = %.2f ' %HX)\n",
+ "r=fs\n",
+ "R=r*HX #information rate\n",
+ "print('bits/sec R = %.2f' %R)\n",
+ "print('Approximation error')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "bits/message H(X) = 2.74 \n",
+ "bits/sec R = 54828.92\n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.19, Page No 476 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "from array import *\n",
+ "#Find Channel Matrix,joint probability\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.5\n",
+ "px2=0.5\n",
+ "py1x1=0.9\n",
+ "py2x1=0.1\n",
+ "py1x2=0.2\n",
+ "py2x2=0.8\n",
+ "PYX=[[py1x1,py2x1],[py1x2,py2x2]]\n",
+ "PX=[[px1,px2]]\n",
+ "PY = [[0,0],\n",
+ " [0,0]]\n",
+ "PXY = [[0,0],\n",
+ " [0,0]]\n",
+ "\n",
+ "for i in range(len(PYX)):\n",
+ " # iterate through columns of Y\n",
+ " for j in range(len(PX[0])):\n",
+ " # iterate through rows of Y\n",
+ " for k in range(len(PX)):\n",
+ " PY[i][j] += PYX[i][k] * PX[k][j]\n",
+ "print(' PY ARRAY = \\n')\n",
+ "for r in PY:\n",
+ " print(r)\n",
+ "PXd=[[px1,0],[0,px2]]\n",
+ "\n",
+ "\n",
+ "for i in range(len(PXd)):\n",
+ " # iterate through columns of Y\n",
+ " for j in range(len(PYX[0])):\n",
+ " # iterate through rows of Y\n",
+ " for k in range(len(PYX)):\n",
+ " PXY[i][j] += PXd[i][k] * PYX[k][j]\n",
+ "\n",
+ " \n",
+ "print(' \\n PXY ARRAY = \\n')\n",
+ "for r in PXY:\n",
+ " print(r)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " PY ARRAY = \n",
+ "\n",
+ "[0.45, 0.45]\n",
+ "[0.1, 0.1]\n",
+ " \n",
+ " PXY ARRAY = \n",
+ "\n",
+ "[0.45, 0.05]\n",
+ "[0.1, 0.4]\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.35, Page No 498"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Channel is aproximated by the AWGN Channel\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=4000.0\n",
+ "S=0.1*10**-3\n",
+ "n=2*10**-12\n",
+ "\n",
+ "#Calculation\n",
+ "N=n*B\n",
+ "C=B*math.log(1+(S/N),2) #Capacity of Channel\n",
+ "C=C/1000.0\n",
+ "#Result\n",
+ "print(' Capacity of Channel C=%.3f(10^3) b/s ' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Capacity of Channel C=54.439(10^3) b/s \n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36i, Page No 499"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "fm=4000.0\n",
+ "fs=2*fm\n",
+ "n=1.25\n",
+ "\n",
+ "#Calculation\n",
+ "r=fs*n\n",
+ "pxi=1/256.0\n",
+ "HX=-math.log(pxi,2)\n",
+ "R=r*HX\n",
+ "R=R/1000\n",
+ "print('Information Rate R= %.f kb/s' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Information Rate R= 80 kb/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36ii, Page No 499"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=10*10**3.0\n",
+ "SN=20.0\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=10**(SN/10.0)\n",
+ "C=B*math.log(1+(SNR),2)\n",
+ "C=C/1000\n",
+ "\n",
+ "#Result\n",
+ "print('The channel capacity = %.2f 10^3 b/s' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The channel capacity = 66.58 10^3 b/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36iii, Page No 499"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "C=8*10**4.0\n",
+ "B=10**4.0\n",
+ "\n",
+ "#Calculation\n",
+ "SN=2**(C/B)-1\n",
+ "SNR=10*math.log(SN,10) #SNR\n",
+ "\n",
+ "#Result\n",
+ "print(' The S/N ratio required for error-free transmission =%.2f dB ' %SNR) #required SNR is greater that 24.064\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The S/N ratio required for error-free transmission =24.07 dB \n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.36iv, Page No 499 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#assume that succeissive samples are statistically independent\n",
+ "\n",
+ "#Variable Declaration\n",
+ "SN=20.0\n",
+ "\n",
+ "#Calculation\n",
+ "SNR=10**(SN/10.0)\n",
+ "C=8*10**4.0\n",
+ "B=C/(math.log(1+SNR,2)) #Bandwidth\n",
+ "B=B/1000\n",
+ "\n",
+ "#Result\n",
+ "print('Bandwidth required for AWGN channel B =%.2f kHz ' %B)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bandwidth required for AWGN channel B =12.02 kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.37, Page No 502"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find code efficiency,redundancy\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.9\n",
+ "px2=0.1\n",
+ "n1=1.0\n",
+ "n2=1.0\n",
+ "\n",
+ "#Calculation\n",
+ "L=px1*n1+px2*n2 #code leght\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)\n",
+ "n=(HX/L) #code efficiency\n",
+ "n=n*100\n",
+ "\n",
+ "print('Code efficiency = %.1f percent' %n)\n",
+ "r=(100-n) #code reduncy\n",
+ "print('Code redundancy = %.1f percent' %r)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Code efficiency = 46.9 percent\n",
+ "Code redundancy = 53.1 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.38, Page No 502"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find code efficiency,redundancy\n",
+ "\n",
+ "#Variable Declaration\n",
+ "pa1=0.81\n",
+ "pa2=0.09 \n",
+ "pa3=0.09\n",
+ "pa4=0.01 \n",
+ "n1=1\n",
+ "n2=2 \n",
+ "n3=3\n",
+ "n4=3 \n",
+ "\n",
+ "#Calculation\n",
+ "L=pa1*n1+pa2*n2+pa3*n3+pa4*n4\n",
+ "HX2=pa1*math.log(1/pa1,2)+pa2*math.log(1/pa2,2)+pa3*math.log(1/pa3,2)+pa4*math.log(1/pa4,2)\n",
+ "n=HX2/L*100\n",
+ "\n",
+ "#Result\n",
+ "print(' code efficiency = %.2f percent' %n)\n",
+ "\n",
+ "r=(100-n) #code reduncy\n",
+ "print(' code redundancy = %.1f percent' %r)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " code efficiency = 72.71 percent\n",
+ " code redundancy = 27.3 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.44, Page No 507"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find efficiency of the code\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=1/2.0\n",
+ "px2=1/4.0\n",
+ "px3=1/8.0\n",
+ "px4=1/8.0\n",
+ "n1=1.0\n",
+ "n2=2.0\n",
+ "n3=3.0\n",
+ "n4=3.0\n",
+ "\n",
+ "#Calculation\n",
+ "#information content of each symbol\n",
+ "Ix1=-math.log(px1,2)\n",
+ "Ix2=-math.log(px2,2)\n",
+ "Ix3=-math.log(px3,2)\n",
+ "Ix4=-math.log(px4,2)\n",
+ "\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2)+px4*math.log(1/px4,2)\n",
+ "L=px1*n1+px2*n2+px3*n3+px4*n4\n",
+ "\n",
+ "n=HX/L*100\n",
+ "\n",
+ "#Result\n",
+ "print('Ccode efficiency = %.f Percent' %n)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Ccode efficiency = 100 Percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.50, Page No 512"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy ,information rate\n",
+ "#If there are 16 outcomes per second\n",
+ "\n",
+ "#Variable Declaration\n",
+ "P1=1/2.0\n",
+ "P2=1/4.0\n",
+ "P3=1/8.0\n",
+ "P4=1/16.0\n",
+ "P5=1/32.0\n",
+ "P6=1/32.0\n",
+ "r=16 #message rate\n",
+ "\n",
+ "#Calculation\n",
+ "H=P1*math.log(1/P1,2)+P2*math.log(1/P2,2)+P3*math.log(1/P3,2)+P4*math.log(1/P4,2)+P5*math.log(1/P5,2)+P6*math.log(1/P6,2)\n",
+ "#Entropy of system\n",
+ "\n",
+ "#Result\n",
+ "print('1. Entropy of system H = %.2f bits/message ' %H)\n",
+ "R=H*r #R=Entropy*message rate\n",
+ "print(' 2. Information rate R = %.f bits/sec ' %R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. Entropy of system H = 1.94 bits/message \n",
+ " 2. Information rate R = 31 bits/sec \n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.51, Page No 512"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Calculate H(X) ,H(Y)\n",
+ "\n",
+ "#Variable Declaration\n",
+ "px1=0.3\n",
+ "px2=0.4\n",
+ "px3=0.3\n",
+ "\n",
+ "#Calculation\n",
+ "HX=px1*math.log(1/px1,2)+px2*math.log(1/px2,2)+px3*math.log(1/px3,2) #Entropy of X\n",
+ "\n",
+ "\n",
+ "print(' 1.Entropy of X H(X)=%.3f bits/symbol ' %HX)\n",
+ "\n",
+ "PYX=[[0.8, 0.2, 0],[ 0, 1, 0],[ 0, 0.3, 0.7]]\n",
+ "PX=[[px1, px2, px3]]\n",
+ "PXY = [[0,0,0],\n",
+ " [0,0,0],\n",
+ " [0,0,0]]\n",
+ "\n",
+ "for i in range(len(PYX)):\n",
+ " # iterate through columns of PXd\n",
+ " for j in range(len(PX[0])):\n",
+ " # iterate through rows of PYX\n",
+ " for k in range(len(PX)):\n",
+ " PXY[i][j] += PYX[i][k] * PX[k][j]\n",
+ "\n",
+ "py1=PXY[0][0]\n",
+ "py2=PXY[0][1]\n",
+ "py3=PXY[0][2]\n",
+ "HY=py1*math.log(1/py1,2)+py2*math.log(1/py2,2)+py3*math.log(1/py3,2) #Entropy of Y\n",
+ "print(' 2. Entropy of Y H(Y)= %.2f bits/symbol ' %HY)\n",
+ "print('Approximation error')\t\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1.Entropy of X H(X)=1.571 bits/symbol \n",
+ " 2. Entropy of Y H(Y)= 1.51 bits/symbol \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.52, Page No 513"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source ,entropy of second order extension\n",
+ "\n",
+ "#Variable Declaration\n",
+ "P1=0.7\n",
+ "P2=0.15\n",
+ "P3=0.15\n",
+ "\n",
+ "#Calculation\n",
+ "HX=P1*math.log(1/P1,2)+P2*math.log(1/P2,2)+P3*math.log(1/P3,2) #Entropy of source\n",
+ "print(' 1. Entropy of system H(X)=%.2f bits/symbol ' %HX)\n",
+ "#H(X^n)=n*H(X)\n",
+ "n=2 #for second order\n",
+ "HX2=n*HX\n",
+ "\n",
+ "#Result\n",
+ "print(' 2. Entropy of second order system extension of source can be H(X^2)=%.2f bits/symbol ' %(HX*2))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1. Entropy of system H(X)=1.18 bits/symbol \n",
+ " 2. Entropy of second order system extension of source can be H(X^2)=2.36 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.54, Page No 514"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "S0=1/3.0\n",
+ "S1=1/6.0\n",
+ "S2=1/4.0\n",
+ "S3=1/4.0\n",
+ "\n",
+ "#Calculation\n",
+ "HX=S0*math.log(1/S0,2)+S1*math.log(1/S1,2)+S2*math.log(1/S2,2)+S3*math.log(1/S3,2) #EntroSy of source\n",
+ "\n",
+ "#Result\n",
+ "print(' Entropy of system H(X)=%.2f bits/symbol ' %HX)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Entropy of system H(X)=1.96 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.56, Page No 515"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Information capacity of telephone\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=3.4*10**3\n",
+ "SNR=30.0\n",
+ "\n",
+ "#Calculation\n",
+ "SN=10**(SNR/10)\n",
+ "C=B*math.log(1+SN,2) #Information capacity\n",
+ "C=C/1000\n",
+ "\n",
+ "#Result\n",
+ "print(' Information capacity of telephone is C = %.2f kbps ' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Information capacity of telephone is C = 33.89 kbps \n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.59, Page No 516"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "S0=1/3.0\n",
+ "S1=1/6.0\n",
+ "S2=1/4.0\n",
+ "S3=1/4.0\n",
+ "\n",
+ "#Calculation\n",
+ "HX=S0*math.log(1/S0,2)+S1*math.log(1/S1,2)+S2*math.log(1/S2,2)+S3*math.log(1/S3,2) #EntroSy of source\n",
+ "\n",
+ "#Result\n",
+ "print(' Entropy of system H(X)=%.2f bits/symbol ' %HX)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Entropy of system H(X)=1.96 bits/symbol \n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.60, Page No 516"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "m1=1/2.0\n",
+ "m2=1/4.0\n",
+ "m3=1/8.0\n",
+ "m4=1/16.0\n",
+ "m5=1/16.0\n",
+ "\n",
+ "#Calculation\n",
+ "L=(m1*1)+(m2*2)+(m3*3)+(2*(m4)*4)\n",
+ "\n",
+ "#Result\n",
+ "print(' Average number of bits per message =%.2f bits ' %L)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Average number of bits per message =1.88 bits \n"
+ ]
+ }
+ ],
+ "prompt_number": 27
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.61, Page No 517"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find Information capacity of telephone\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=3.4*10**3\n",
+ "SNR=30.0\n",
+ "\n",
+ "#Calculation\n",
+ "SN=10**(SNR/10)\n",
+ "C=B*math.log(1+SN,2) #Information capacity\n",
+ "C=C/1000\n",
+ "\n",
+ "#Result\n",
+ "print(' Information capacity of telephone is C = %.2f kbps ' %C)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Information capacity of telephone is C = 33.89 kbps \n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.62, Page No 517"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "p1=4.0\n",
+ "m1=0.5\n",
+ "m2=0.5\n",
+ "m3=0.375\n",
+ "m4=0.375\n",
+ "m5=0.375\n",
+ "m6=0.375\n",
+ "\n",
+ "#Calculation\n",
+ "I1=p1*math.log(1/p1,2) \n",
+ "HX=m1*math.log(1/m1,2)+m2*math.log(1/m2,2)+m3*math.log(1/m3,2)+m4*math.log(1/m4,2)+m5*math.log(1/m5,2)+m6*math.log(1/m6,2) #EntroSy of source\n",
+ "\n",
+ "#Result\n",
+ "print(' Entropy of system H(X)=%.2f bits/symbol ' %HX)\n",
+ "print('Approximation error')\t"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Entropy of system H(X)=3.12 bits/symbol \n",
+ "Approximation error\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.65, Page No 519"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find entropy of source \n",
+ "\n",
+ "#Variable Declaration\n",
+ "S0=1/2.0\n",
+ "S1=1/4.0\n",
+ "S2=1/8.0\n",
+ "S3=1/8.0\n",
+ "n=1\n",
+ "\n",
+ "#Calculation\n",
+ "H=S0*math.log(1.0/S0,2)+S1*math.log(1.0/S1,2)+S2*math.log(1.0/S2,2)+S3*math.log(1.0/S3,2) #EntroSy of source\n",
+ "L=H*n\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print(' Code length =%.2f bits/messages ' %L)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Code length =1.75 bits/messages \n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.67, Page No 520"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "#Find channel capacity and new bandwidth\n",
+ "\n",
+ "#Variable Declaration\n",
+ "B=8*10**3\n",
+ "SNR=31.0\n",
+ "SNR2=61\n",
+ "\n",
+ "#Calculation\n",
+ "C=B*math.log(1+SNR,2) #Information capacity\n",
+ "B2=C/math.log(1+SNR2,2)\n",
+ "#Result\n",
+ "print(' Channel capacity is C = %.2f x 10^3 bits/sec ' %(C/1000))\n",
+ "print(' New Bandwidth is C = %.2f x kHz ' %(B2/1000))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Channel capacity is C = 40.00 x 10^3 bits/sec \n",
+ " New Bandwidth is C = 6.72 x kHz \n"
+ ]
+ }
+ ],
+ "prompt_number": 31
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/ChapterNo9.ipynb b/Digital_Communications/ChapterNo9.ipynb
new file mode 100755
index 00000000..8062105c
--- /dev/null
+++ b/Digital_Communications/ChapterNo9.ipynb
@@ -0,0 +1,182 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1> Chpater No 9: ERROR CONTROL CODING<h1>"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.4, Page No 540"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find detected errors,corrected errors\n",
+ "\n",
+ "#initialisation of variables\n",
+ "dmin=5.0\n",
+ "#(s+1)<= dmin number errors can be detected(s)\n",
+ " \n",
+ "#CALCULATIONS\n",
+ "s=dmin-1\n",
+ "\n",
+ "#RESULTS\n",
+ "print(' i)Number of detected errors s <= %.f ' %s)\n",
+ "#(2t+1)<=dmin number errors can be corrected(t)\n",
+ "t=(dmin-1)/2.0\n",
+ "print('ii) Number of corrected errors t<= %.f ' %t)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " i)Number of detected errors s <= 4 \n",
+ "ii) Number of corrected errors t<= 2 \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.17, Page No 569"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Determine all possible code vectors \n",
+ "\n",
+ "m3=1\n",
+ "m2=0\n",
+ "m1=1\n",
+ "m0=0\n",
+ "#M=Message Matrix\n",
+ "#G=Generator Matrix\n",
+ "G=[[1, 0, 1, 1, 0, 0, 0],[0, 1, 0, 1, 1, 0, 0],[0, 0, 1, 0, 1, 1, 0],[0, 0, 0, 1, 0, 1, 1]]\n",
+ "M=[[m3,m2,m1,m0]]\n",
+ "X = [[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0]]\n",
+ "\n",
+ "for i in range(len(G)):\n",
+ " # iterate through columns of PXd\n",
+ " for j in range(len(M[0])):\n",
+ " # iterate through rows of PYX\n",
+ " for k in range(len(M)):\n",
+ " X[i][j] += G[i][k] * M[k][j]\n",
+ "print('The required code word')\n",
+ "for r in range(0,7):\n",
+ " print(X[0][r])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The required code word\n",
+ "1\n",
+ "0\n",
+ "1\n",
+ "0\n",
+ "0\n",
+ "0\n",
+ "0\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.19, Page No 572"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Determine code word \n",
+ "m3=1\n",
+ "m2=0\n",
+ "m1=1\n",
+ "m0=0\n",
+ "#M=Message Matrix\n",
+ "#G=Generator Matrix\n",
+ "G=[[1, 0, 0, 0, 1, 0, 1],[0, 1, 0, 0, 1, 1, 1],[0, 0, 1, 0, 1, 1, 0],[0, 0, 0, 1, 0, 1, 1]]\n",
+ "M=[[m3,m2,m1,m0]]\n",
+ "X = [[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0]]\n",
+ "\n",
+ "\n",
+ "for i in range(len(G)):\n",
+ " # iterate through columns of PXd\n",
+ " for j in range(len(M[0])):\n",
+ " # iterate through rows of PYX\n",
+ " for k in range(len(M)):\n",
+ " X[i][j] += G[i][k] * M[k][j]\n",
+ "print('The required code word')\n",
+ "for r in range(0,7):\n",
+ " print(X[0][r] )\n",
+ " \n",
+ "\n",
+ "print('The code in the book is wrong')\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The required code word\n",
+ "1\n",
+ "0\n",
+ "1\n",
+ "0\n",
+ "0\n",
+ "0\n",
+ "0\n",
+ "The code in the book is wrong\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Digital_Communications/README.txt b/Digital_Communications/README.txt
new file mode 100755
index 00000000..cb9038a1
--- /dev/null
+++ b/Digital_Communications/README.txt
@@ -0,0 +1,10 @@
+Contributed By: Mayur Sabban
+Course: be
+College/Institute/Organization: Vishwakarma Institute of Technology Pune
+Department/Designation: Computer Engg
+Book Title: Digital Communications
+Author: S. Sharma
+Publisher: S. K. Kataria & Sons, New Delhi
+Year of publication: 2013
+Isbn: 9789350142684
+Edition: 6 \ No newline at end of file
diff --git a/Digital_Communications/screenshots/Chapter1.png b/Digital_Communications/screenshots/Chapter1.png
new file mode 100755
index 00000000..ecbda1c6
--- /dev/null
+++ b/Digital_Communications/screenshots/Chapter1.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter2.png b/Digital_Communications/screenshots/chapter2.png
new file mode 100755
index 00000000..cfb39197
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter2.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter2_1.png b/Digital_Communications/screenshots/chapter2_1.png
new file mode 100755
index 00000000..4eac12f5
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter2_1.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter2_2.png b/Digital_Communications/screenshots/chapter2_2.png
new file mode 100755
index 00000000..2aa76318
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter2_2.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter2_3.png b/Digital_Communications/screenshots/chapter2_3.png
new file mode 100755
index 00000000..2aa76318
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter2_3.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter3.png b/Digital_Communications/screenshots/chapter3.png
new file mode 100755
index 00000000..bd8ace20
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter3.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter3_1.png b/Digital_Communications/screenshots/chapter3_1.png
new file mode 100755
index 00000000..b59f5a6f
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter3_1.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter3_2.png b/Digital_Communications/screenshots/chapter3_2.png
new file mode 100755
index 00000000..9e929daa
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter3_2.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter3_3.png b/Digital_Communications/screenshots/chapter3_3.png
new file mode 100755
index 00000000..9e929daa
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter3_3.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter4.png b/Digital_Communications/screenshots/chapter4.png
new file mode 100755
index 00000000..9160481e
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter4.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter4_1.png b/Digital_Communications/screenshots/chapter4_1.png
new file mode 100755
index 00000000..230f9193
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter4_1.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter4_2.png b/Digital_Communications/screenshots/chapter4_2.png
new file mode 100755
index 00000000..31a0c9c2
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter4_2.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter4_3.png b/Digital_Communications/screenshots/chapter4_3.png
new file mode 100755
index 00000000..31a0c9c2
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter4_3.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter6.png b/Digital_Communications/screenshots/chapter6.png
new file mode 100755
index 00000000..47807122
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter6.png
Binary files differ
diff --git a/Digital_Communications/screenshots/chapter7.png b/Digital_Communications/screenshots/chapter7.png
new file mode 100755
index 00000000..12c93548
--- /dev/null
+++ b/Digital_Communications/screenshots/chapter7.png
Binary files differ