summaryrefslogtreecommitdiff
path: root/Analog_and_Digital_Communications_by_H_P_Hsu/CHAPTER06.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Analog_and_Digital_Communications_by_H_P_Hsu/CHAPTER06.ipynb')
-rwxr-xr-xAnalog_and_Digital_Communications_by_H_P_Hsu/CHAPTER06.ipynb380
1 files changed, 0 insertions, 380 deletions
diff --git a/Analog_and_Digital_Communications_by_H_P_Hsu/CHAPTER06.ipynb b/Analog_and_Digital_Communications_by_H_P_Hsu/CHAPTER06.ipynb
deleted file mode 100755
index 3fe5c8b4..00000000
--- a/Analog_and_Digital_Communications_by_H_P_Hsu/CHAPTER06.ipynb
+++ /dev/null
@@ -1,380 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:a14c7a989e8c3ea4932d8ef52a48aca6495d802f38f7487ab2fe14fa0d728058"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "CHAPTER06:PROBABILITY AND RANDOM VARIABLES"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E07 : Pg 6.16"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.16\n",
- "# Example 6.7\n",
- "# Given\n",
- "# Pdot=2*Pdash and Pdot+Pdash=1\n",
- "# Therfore, on solving using linear equations\n",
- "import math \n",
- "#a=([1, -2],[1, 1]);\n",
- "##c=([0],[1]);\n",
- "#b=1/(a)*c;\n",
- "Pdash=0.3333333;#b(1,1);\n",
- "Pdot=0.6666667;#b(2,1);\n",
- "print'Pdot:',Pdot\n",
- "print'Pdash:',Pdash"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Pdot: 0.6666667\n",
- "Pdash: 0.3333333\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E14 : Pg 6.18"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.18\n",
- "# Example 6.14\n",
- "# Given\n",
- "p=0.1;\n",
- "q=0.2;\n",
- "Pm0=0.5;\n",
- "Pr1bym0=p;\n",
- "Pr0bym1=q;\n",
- "# (a) Find Pr0 and Pr1\n",
- "Pm1=1-Pm0;\n",
- "Pr0bym0=1-Pr1bym0;\n",
- "Pr1bym1=1-Pr0bym1;\n",
- "\n",
- "# By formula\n",
- "# P(r0)=(P(r0/m0)*P(m0))+(P(r0/m1)*P(m1);\n",
- "# P(r1)=(P(r1/m0)*P(m0))+(P(r1/m1)*P(m1);\n",
- "Pr0=(Pr0bym0*Pm0)+(Pr0bym1*Pm1);\n",
- "Pr1=(Pr1bym0*Pm0)+(Pr1bym1*Pm1);\n",
- "print'P(r0):',Pr0\n",
- "print'P(r1):',Pr1\n",
- "# (b)P(m0/r0)\n",
- "# Using Bayes Rule\n",
- "# P(m0/r0)=(P(m0)*P(r0/m0)/P(r0))\n",
- "Pm0byr0=(Pm0*Pr0bym0)/Pr0;\n",
- "print'P(m0/r0):',Pm0byr0\n",
- "# (c)P(m1/r1)\n",
- "# Using Bayes Rule\n",
- "# P(m1/r1)=(P(m1)*P(r1/m1)/P(r1))\n",
- "Pm1byr1=(Pm1*Pr1bym1)/Pr1;\n",
- "print'P(m1/r1):',Pm1byr1\n",
- "\n",
- "# (d)Probabilty error\n",
- "# As Pe=(P(r1/m0)*P(m0))+(P(r0/m1)*P(m1))\n",
- "Pe=(Pr1bym0*Pm0)+(Pr0bym1*Pm1);\n",
- "print'Probability error:',Pe\n",
- "\n",
- "# (e)Probabilty that is transmitted correctly\n",
- "# As Pc=(P(r0/m0)*P(m0))+(Pr1bym1*Pm1)\n",
- "\n",
- "Pc=(Pr0bym0*Pm0)+(Pr1bym1*Pm1);\n",
- "print'Probabilty that is transmitted correctly:',Pc"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "P(r0): 0.55\n",
- "P(r1): 0.45\n",
- "P(m0/r0): 0.818181818182\n",
- "P(m1/r1): 0.888888888889\n",
- "Probability error: 0.15\n",
- "Probabilty that is transmitted correctly: 0.85\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E16 : Pg 6.21"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.21\n",
- "# Example 6.16\n",
- "# Given\n",
- "p=0.4;\n",
- "Pp=p;\n",
- "q=0.3;\n",
- "Pn=q;\n",
- "a=1.; # i start value\n",
- "b=6.; # i end value\n",
- "# (a)Probabilty that all pulses are positive\n",
- "s=1.;\n",
- "for i in range(1,6):\n",
- " s=s*Pp;\n",
- "print'Probabilty that all pulses are positive:',s\n",
- "\n",
- "# (b)Pulses are positive ,positive, positive, zero,zero,negative\n",
- "Pz=1.-(p+q);\n",
- "s1=(Pp**3.)*(Pz**2.)*Pn;\n",
- "print'Probabilty that all pulses are positive ,positive, positive, zero,zero,negative:',s1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Probabilty that all pulses are positive: 0.01024\n",
- "Probabilty that all pulses are positive ,positive, positive, zero,zero,negative: 0.001728\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E17 : Pg 6.21"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.21\n",
- "# Example 6.17\n",
- "# Given\n",
- "import math \n",
- "P1=0.6;\n",
- "P0=0.4;\n",
- "n=5.; # Five digit sequence\n",
- "j=2.; # two outcomes 0 and 1\n",
- "\n",
- "# (a)1,1,0,0,0\n",
- "xf=(math.factorial(n))/((math.factorial(j))*(math.factorial(n-j)));\n",
- "s=xf*(P1**j)*(P0**(n-j));\n",
- "print'Probability for 1,1,0,0,0:',s\n",
- "\n",
- "# (b)atleast 3 1's\n",
- "# P(X>=3)=1-P(X<=2)\n",
- "# Here y=1-x\n",
- "x=0;\n",
- "for k in range(0,2):\n",
- " f=(math.factorial(n))/((math.factorial(k))*(math.factorial(n-k)));\n",
- " x=x+(f*((P1**k)*(P0**(n-k))));\n",
- "y=1.-x;\n",
- "print'Probability for atleast three 1 s:',y"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Probability for 1,1,0,0,0: 0.2304\n",
- "Probability for atleast three 1 s: 0.91296\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E20 : Pg 6.23"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.23\n",
- "# Example 6.20\n",
- "# Given\n",
- "import math \n",
- "pe=0.01; # Error probability\n",
- "\n",
- "# (a) Probabilty of more than one error in 10 recieved digits\n",
- "n=10.;\n",
- "# As P(X>1)=1-P(X=0)-P(X=1)\n",
- "# Let x=P(X>1)\n",
- "# s=P(X=0)+P(X=1)\n",
- "s=0;\n",
- "for t in range(0,1):\n",
- " f=(math.factorial(n))/((math.factorial(t))*(math.factorial(n-t)));\n",
- " s=s+(f*(pe**t)*((1-pe)**(n-t)));\n",
- "x=1-s;\n",
- "print'Probabilty of more than one error in 10 recieved digits:',x\n",
- "\n",
- "# (b)Using Poisson approximation\n",
- "# P(X=k)~[{(%exp)**(-n*p)}*{((n*p)**k)}]/k factorial\n",
- "s1=0;\n",
- "for k in range(0,1):\n",
- " j=math.factorial(k);\n",
- " s1=s1+((math.exp(-n*pe))*(((n*pe)**k)))/j;\n",
- "x1=1.-s1;\n",
- "print'Using Poisson Approximation:',x1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Probabilty of more than one error in 10 recieved digits: 0.0956179249912\n",
- "Using Poisson Approximation: 0.095162581964\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E23 : Pg 6.23"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.23\n",
- "# Example 6.23\n",
- "# We find, k=1/(b-a)\n",
- "# (b) if a=1 and b=2,P(|x|<c) where c=1/2\n",
- "a=-1.;\n",
- "b=2.;\n",
- "c=1./2.;\n",
- "\n",
- "k=1./(b-a);\n",
- "# P(|x|<c) = P(-c<=x<=c)\n",
- "# Let y\n",
- "x0=-c;x1=c;\n",
- "y=1.;#integrate('1','x',x0,x1);\n",
- "y1=k*y;\n",
- "print'P(|x|<c):',y1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "P(|x|<c): 0.333333333333\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example E41 : Pg 6.34"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Page Number: 6.34\n",
- "# Example 6.41\n",
- "# Given\n",
- "import math \n",
- "n=16.; # binary digits\n",
- "p=0.01; # Probabilty error due to noise\n",
- "\n",
- "# (a) Average errors per block\n",
- "# E(X)=n*p\n",
- "EofX=n*p;\n",
- "print'Average errors per block:',EofX\n",
- "\n",
- "# (b)Varience of errors of block\n",
- "# s=n*p*(1-p)\n",
- "s=n*p*(1.-p);\n",
- "print'Varience of errors per block:',s\n",
- "\n",
- "\n",
- "# (c) Probability that number of errors per block is bgeater or equal than 4\n",
- "i=4.;\n",
- "# AsP(X>=4)=1=P(X<=3)\n",
- "P3=0;\n",
- "for k in range(0,3):\n",
- " f=(math.factorial(n))/((math.factorial(k))*(math.factorial(n-k)));\n",
- " P3=P3+(f*(p**k)*((1-p)**(n-k)));\n",
- "P4=1.-P3;\n",
- "print'Probability that number of errors per block is bgeater or equal than 4:',P4"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Average errors per block: 0.16\n",
- "Varience of errors per block: 0.1584\n",
- "Probability that number of errors per block is bgeater or equal than 4: 0.000507942409291\n"
- ]
- }
- ],
- "prompt_number": 7
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file