最近几天重新复习了有关信息编码的知识,首先跟大家推荐两本书吧。
《数字通信原理与技术》(北京邮电出版社的)
《ldpc原理与应用》
首先先搞清几个概念。
1.什么是分组码?
每个码组的监督码元仅与该码组的信息码元有关,而与其他码组的信息码元无关,这类码称为分组码。在分组码中,监督码元仅监督本码组中的信息码元。
编码效率R=k/n,k是信息位,n-k是监督位,R越大,信息位所占的比重越大,码组传输信息的有效性越高。所以,R说明了分组码传输信息的有效性。d0表示最小码距。d0越大,则从一个码组错为另一个码组的可能性越小,因而检错、纠错能力也就越强。
d0表示最小码距。d0越大,则从一个码组错为另一个码组的可能性越小,因而检错、纠错能力也就越强。
如果码组集合中码组间的最小码距满足:
d0>=e+1
则该码集中的码组具有检测e位错码的能力。
如果d0>=2t+1,则该码集中的码组具有纠正t个错码的能力。
如果d0>=t+e+1(e>t),则该码集中的码组具有纠正t个错码,并检测e个错码的能力。
2.什么是线性码?
线性码中的信息位和监督位是由线性代数方程联系着的。或者说,线性码是按一组线性方程构成的。
3.监督矩阵(或者校验矩阵)H到底表示什么?
H表示的是监督位和信息位之间的关系,只要H给定,编码时监督位和信息位的关系就完全确定了,H的行数就是监督位的数目r。H的每行中1的位置表示相应码元之间存在的监督关系。例如,H的第一行1110100表示监督位a2是由a6a5a4之和决定的。
图传不上去,好气。
下面直接附上我用Python写的代码
已知生成矩阵G,求所有可能生成的码字:
import numpy as np
N=7
K=4
G=np.array([[1,0,0,0,1,1,1],
[0,1,0,0,1,1,0],
[0,0,1,0,1,0,1],
[0,0,0,1,0,1,1]])
b=[] #0000~1111的二进制数
for i in range(16):
a=format(i,'b')
b.append("{:0>4s}".format(a))
v=np.zeros((16,4))
for i in range(16):
v[i]=b[i]
for j in range(4):
v[i][j]=b[i][j] #v是从0000~1111的矩阵
#print(v)
v_=(np.dot(v,G))%2
#print(v_)
#print(v_[1][:4])
for o in range(16):
if np.all(v_[o][:4]==v[o]):
print(v_[o])
已知校验矩阵H,求所有可能生成的码字:
import numpy as np
N=63
K=45
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1 a0]=[a6 a5 a4 a3]×G,所以[a6 a5 a4 a3]只要从0000~1111,找出满足这个等式关系的所有码字即可。
而已知H也是一样。因为H×[a6 a5 a4 a3 a2 a1 a0].T=0即可,.T在Python中表示转置。
我的目标是生成一堆LDPC的码字,然后根据论文《On Deep Learning-Based Channel Decoding》去改进,将原来的polar码改为LDPC码,看看性能有没有提高。