1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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": {}
}
]
}
|