Chpater 9: ERROR CONTROL CODING

In [1]:
#Find  detected errors,corrected errors

#initialisation of variables
dmin=5.0
#(s+1)<= dmin number errors can be detected(s)
 
#CALCULATIONS
s=dmin-1

#RESULTS
print(' i)Number of detected errors  s <=  %.f ' %s)
#(2t+1)<=dmin number errors can be corrected(t)
t=(dmin-1)/2.0
print('ii) Number of corrected errors  t<=  %.f ' %t)
 i)Number of detected errors  s <=  4 
ii) Number of corrected errors  t<=  2 

Example 9.17, Page No 569

In [2]:
#Determine all possible code vectors 

m3=1
m2=0
m1=1
m0=0
#M=Message Matrix
#G=Generator Matrix
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]]
M=[[m3,m2,m1,m0]]
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]]

for i in range(len(G)):
   # iterate through columns of PXd
   for j in range(len(M[0])):
       # iterate through rows of PYX
       for k in range(len(M)):
           X[i][j] += G[i][k] * M[k][j]
print('The required code word')
for r in range(0,7):
         print(X[0][r])
The required code word
1
0
1
0
0
0
0

Example 9.19, Page No 572

In [7]:
#Determine  code word 
m3=1
m2=0
m1=1
m0=0
#M=Message Matrix
#G=Generator Matrix
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]]
M=[[m3,m2,m1,m0]]
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]]


for i in range(len(G)):
   # iterate through columns of PXd
   for j in range(len(M[0])):
       # iterate through rows of PYX
       for k in range(len(M)):
           X[i][j] += G[i][k] * M[k][j]
print('The required code word')
for r in range(0,7):
         print(X[0][r] )
     

print('The code in the book is wrong')
The required code word
1
0
1
0
0
0
0
The code in the book is wrong