TEOI-Channel Codes
TEOI-Channel Codes
Information Theory
Degree in Data Science and Engineering
Lesson 6: Channel coding
2019/20 - Q1
1/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Let us return to the example of the HDD and compare repetition coding and
Shannon channel coding.
For the BSC with p = 0.1, the channel capacity is
2/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
3/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
4/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Channel codes
C : Xk → Xn
c = C(xk )
5/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Fields
Addition
Assuming a, b, c ∈ X ...
The set is closed under addition: a + b ∈ F
Associativity: a + (b + c) = (a + b) + c
Commutativity: a + b = b + a
Additive identity element: a + 0 = a
Additive inverse element: −a ∈ F such that a + (−a) = 0
6/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Fields
Multiplication
Assuming a, b, c ∈ X ...
The set is closed under multiplication: ab ∈ X
Associativity: a(bc) = (ab)c
Commutativity: ab = ba
Distributive over the addition: a(b + c) = ab + ac
Multiplicative identity element: 1a = a
Inverse element: ∀a 6= 0, ∃ a−1 such that a−1 a = 1
A finite field with q = |X | elements is called a Galois field, GF (q), which can
only be defined if q is a prime number or an integer power of a prime. Very
much used fields in coding are GF (2n ), in particular n = 8.
Only X = {0, 1} will be considered in the sequel.
7/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
There are q n vectors in the vector space Vn of dimension n in the field GF (q).
A subset of this space is called a vector subspace S, if two conditions are met:
The all-zeros vector is in S, and
The linear combination of two vectors is in S, i.e. if c1 , c2 ∈ S and
α, β ∈ X , then αc1 + βc2 ∈ S
c1 = 0101 c2 = 0110
The scalar product of two vectors is denoted as ci cTj and defined as the sum of
the products of its elements. Two vectors are orthogonal if its scalar product is
zero.
8/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
c3 = 1000 c4 = 1111
9/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
dmin = min{w(ci − cj ) : ci , cj ∈ C, ci 6= cj }
= min{w(ck ) : ck ∈ C, ck 6= 0}
, wmin
since the linearity of the code implies that a sum of codewords is a codeword.
The key idea behind block codes is: take a number of vectors in Vn (the
codebook) that form a subspace. If due to channel errors any element of the
codeword is changed, we can still recover the codeword as long as it is not
identified as another codeword.
10/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
11/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
As an example, let us take a (n, k) = (127, 92) code. From the 2127 possible
codewords, only 292 ' 5 × 1027 are selected, but using them still implies a huge
lookup table! Fortunatelly we can generate codewords on the fly from the
generator matrix.
12/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
As a result, the codeword is split between parity check symbols and systematic
symbols:
cm = [cp |xm ]
13/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Associated with the (n, k) code, we can define a (n, n − k) linear dual code,
whose generator matrix is H. The n − k rows of H form a base of the null
space of the rows of G. Any codeword belonging to the code is orthogonal to
any codeword generated with the dual code.
Therefore:
GHT = 0
Solving the linear equation, it follows that
H = [In−k | − PT ]
Hence, for any codeword cm HT = 0, and hence we have an algebraic tool that
allows detecting errors.
14/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
The minimum distance is dmin = 3 and its rate is R = 2/5. The parity check
matrix is
1 0 0 1 0
H= 0 1 0 0 1
0 0 1 1 1
It can be verified that GHT = 0.
dmin ≤ n − k + 1
15/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Optimum decoding
Assume that a transmitted codeword c is received in error r = c + e after
having passed through a noisy channel. The decoder operates on r and returns
ĉ = g(r). An error event E occurs with probability Pr(E|r) = Pr(ĉ 6= c|r), and
the total error probability is
X
Pr(E) = Pr(E|r) Pr(r).
r
minimize Pr(E|r)
c
or also
maximize Pr(ĉ = c|r) ⇔ maximize Pr(r|ĉ = c) Pr(c)
c c
that is, ĉ is the most likely codeword given r (maximum a posteriori decoder).
If the channel is memoryless, all errors in the elements of the received codeword
are independent so we can write
n
Y
Pr(r|c) = Pr(ri |ci )
i=1
16/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Optimum decoding
Let us assume all codewords are equally likely. Since the logarithm is a
monotonous increasing function we can use it in the optimization:
n
X
log Pr(r|c) = log Pr(ri |ci )
i=1
ĉ = argmin d(r, c)
c
Check the figure in slide 11: any black dot corresponding to a possible received
vector will be decoded into the closest codeword. Therefore, optimum decoding
entails comparison of r with all possible 2k codewords! For long codes with
large codebooks the complexity may be prohibitive.
17/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Fortunatelly, the algebraic structure of linear block codes allow simple decoding
using the parity check matrix H.
18/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Construction of the standard array D: include in the first row all possible
codewords ci (they form a vector space). In the second row, put all vectors
resulting from the sum of a coset leader e2 (a vector that is not a codeword)
and the vectors in the first row. For the third row, take as coset leader e3 a
vector that did not appear in the previous rows and form the third row by
summing it to the vectors of the first row. Follow in this way until 2n−k rows
are completed:
c1 c2 c3 ... c 2k
e2 c2 + e2 c3 + e2 ... c 2k + e 2
e3 c 2 + e3 c3 + e3 . . . c 2k + e 3
.. .. .. ..
. . . .
e2n−k c2 + e2n−k c3 + e2n−k ... c2k + e2n−k
Row j (called the j-th coset) contains all possible received vectors resulting
from a particular error pattern ej , and forms an affine space.
19/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
20/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Proof. If the minimum distance of the code is dmin , any two codewords differ
in at least dmin elements. Therefore, no error vector of weight dmin − 1 or less
can convert one codeword into another. In that case, the received vector will
generate a non-zero syndrome.
The code cannot detect all error vectors of weight dmin . In practice, the code
can detect many error vectors of weight dmin and more. The code can detect
2n − 2k error vector.
21/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Theorem (6.0)
All the 2k vectors of a coset have the same syndrome. The syndromes for
different cosets are different.
Proof. By construction of D (see slide 19) every vector in a coset has the same
syndrome
(el + ci )HT = el HT + ci HT = el HT
which is the syndrome of the coset leader.
For the second part of the theorem, let ej and el be the coset leaders of the
jth and lth cosets, where j < l. Assume that the syndromes of these coset
leaders are equal
ej HT = el HT
(ej + el )HT = 0.
This implies that ej + el is a codeword in C, say ci . Thus, ej + el = ci , and
el = ej + ci . This implies that el is in the jth coset, which contradicts the
construction of D. Therefore, no two cosets have the same syndrome.
22/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Theorem (6.1)
Every (n, k) linear block code is capable of correcting up to 2n−k error patterns.
Proof. Let cj be the transmitted codeword. Only if the error vector induced by
the channel e is one of the 2n−k coset leaders, the received vector is in the j-th
column of D. Otherwise, cj + e will be associated to some syndrome, and
hence to a different coset leader el plus a non-zero codeword ci (remember all
possible vectors in {0, 1}n appear in the array). Hence,
r = cj + e = cj + el + ci = el + (cj + ci ) = el + cs
23/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Example (continued). For the (5, 2) linear block code, with dmin = 3
1 0 1 1 0
G= 0 1 1 0 1
Here, coset leaders are all vectors of weight 1 plus two vectors of weight 2
selected among those having different syndrome. Note that if dmin = 1, no
vector of weight 1 could have been used as a coset leader. Why? If a coset
leader lead us to another codeword, errors cannot be detected.
24/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Syndrome decoding is optimal if coset leaders are properly chosen.
Theorem (6.2)
If the coset leaders are the minimum weight vectors, syndrome decoding
minimizes the probability of error.
Proof. Let r be the received vector. If located in the i-th column of D and in
the l-th coset, then r is decoded into ci . Because r = el + ci , the distance
between r and ci is
where the inequality appears if coset leaders are chosen of minimum weight.
Finally, check the optimum receiver in slide 17.
Note that minimum weight errors are the most likely to occur in a BSC.
25/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
Theorem (6.3)
For a (n, k) linear block code C with minimum distance dmin , all the vectors of
weight t = b(dmin − 1)/2c or less can be used as coset leaders.
26/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Syndrome decoding
A block code of minimum distance dmin can correct all errors of weight equal
or lower than t, and cannot correct all errors of weight t + 1.
Theorem (6.4)
For an (n, k) linear block code C with minimum distance dmin , if all vectors of
weight t or less are used as coset leaders, there is at least one vector of weight
t + 1 that cannot be used as a coset leader.
Proof. Let v ∈ C such that w(v) = dmin . Let x, y be two vectors satisfying
1 x+y =v
2 x, y do not have non-zero components in common places.
By 1) and linearity of the code, x, y must be in the same coset, and by 2)
27/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Looking into the structure of D and the theorems above, a block code can
Not detect 2k − 1 error vectors: those codewords altered into another
codeword.
Detect 2n − 2k error vectors: those generating a non-zero syndrome
vector; for large n, 2k − 1 2n − 2k .
Correct 2n−k error vectors: those error vectors equal to a coset leader;
they are a small fraction of those detected for large n.
28/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Note that this is an upper bound of the bit error probability. Let us evaluate
the four terms:
Pr(E|no detect) = 1, if the error is not detected, it cannot be corrected!
Pr(no detect) is given in next slide as Pu (E). Depends on the code and
on the channel transition probabilities.
Pr(E|detect) is given in the following slides as Pd (E).
Pr(detect) = 1 − Pr(no detect)
29/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
We can compute an upper bound for the undetected errors probability on the
whole set Γ of possible (n, k) linear block codes. Since all are constructed
using the generator matrix G, there are 2k(n−k) possible parity matrices P.
Let us compute a bound on this error for the ensemble of linear block codes. If
the code is selected randomly, P (Cj ) = 2−k(n−k) and then the average
probability of error is:
|Γ| n |Γ|
X X X
P̄u (E) = P (Cj )Pu (E|Cj ) = 2−k(n−k) pi (1 − p)n−i Aj (i)
j=1 j=1 j=1
30/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
and hence
n
!
−(n−k)
X n i
P̄u (E) ≤ 2 p (1 − p)n−i = 2−(n−k) (1 − (1 − p)n ) ≤ 2−(n−k)
i=1
i
That is, there exists (n, k) linear block codes Ck whose Pu (E|Ck ) is decreasing
faster than exponentially with the number of parity check bits (n − k).
Only a few codes have been discovered to exactly reach this bound.
31/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
33/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Exact expressions for the probability of error can also be obtained for
quasi-perfect codes, for which all spheres of radius t are disjoint and the
spheres of radius t + 1 overlap (as a consequence of the weight of some coset
leaders is t + 1). No more than t + 1 errors can be corrected.
34/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
For quasi perfect codes, the total number of vectors outside the spheres is
t
!
n k
X n
Nt+1 = 2 − 2
i=0
i
that we can equally divide among the 2k codewords so that each sphere is
enlarged by adding !
t
n−k
X n
βt+1 = 2 −
i=0
i
vectors of distance t + 1 from the transmitted codeword. Consequently, from
n
all t+1 error vectors of distance t + 1 we can correct βt+1 . Thus the error
probability is given by
n
! " ! #
X n i n−i n
Pd (E) = p (1 − p) + − βt+1 pt+1 (1 − p)n−t−1
i=t+2
i t + 1
35/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Perfect codes
Why are they so rare? It is hard to pack spheres in high dimensional spaces.
36/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Bounds on dmin
Given that t determines the error rate performance of the code, we need to
compute a value for dmin given a code. Unfortunately there is no simple way of
computing it, and many bounds have been derived. The bounds shown below
provide necessary conditions for Rc given a desired distance dmin .
Singleton bound
Use the bound dmin ≤ n − k + 1. Since dmin − 1 ' 2t, a high power
correction is achieved if n − k is large, at least, n − k ≥ 2t. Codes for
which this bound is met with equality are called Maximum Distance
Separable codes (only repetition codes and Reed-Solomon codes).
dmin 1
δmin = ≤ 1 − Rc +
n n
for large n
δmin ≤ 1 − Rc
37/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Bounds on dmin
Hamming bound
Depart from the inequality
t
!
(n−k)
X n
2 ≥
i=0
i
38/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Bounds on dmin
40/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Hamming codes
Richard Hamming
41/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Hamming codes
These are codes of dmin = 3. For any m = n − k ≥ 3 there is a code such that
Codeword length: n = 2m − 1
Information symbols: k = 2m − m − 1
Error correcting capability: t = 1
m
Rate: Rc = 1 − 2m −1
Parity check matrix H: its 2m − 1 columns contain all integers of m
binary digits except zero.
Weight enumerator function, is the set of coefficients of the polynomial
1 h i
A(z) = (1 + z)n + n(1 − z)(1 − z 2 )(n−1)/2
n+1
42/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Hamming codes
43/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Hamming codes
Block probability of detected and not corrected errors, for several (n, k)
Hamming codes versus transition probability of a BSC. Uncoded block
probability in dashed line.
44/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
45/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
46/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Probability of detected and not corrected errors for the Golay code versus
transition probability of a BSC
47/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Reed-Solomon codes
48/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Reed-Solomon codes
49/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
LDPC codes
R = k/n = 1 − wc /wr .
LDPC codes
Examples taken from D. Mackay, Information Theory, Inference, and Learning Algorithms, Cambridge Press, 2003 51/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
LDPC codes
52/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
LDPC codes
Encoding. It is known that only irregular LDPC codes are able to achieve
close to capacity rates at low probability of error1 . These codes have a
variable number of ones in each row and column of H.
Decoding. Optimum decoding is an NP-hard problem. Many suboptimum
iterative algorithms exist that take advantage of the sparse structure of
matrix H.
The bit-flipping family of algorithms operate basically as follows:
1: compute the syndrome s = rHT
2: iter=0
3: if (s == 0 or iter > max num iter) then stop
4: otherwise, take the nonzero components of s and flip those
components of r that appear in the largest number of
unsatisfied parity check equations
5: iter=iter+1
6: go to 1
1
S.Y. Chung, G.D. Forney Jr., T. Richardson, R. Urbanke, “On the Design of Low-Density Parity-Check Codes
within 0.0045 dB of the Shannon Limit,” IEEE Commun. Lett., vol. 5, pp. 58–60, 2001
53/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Iterative decoding of an
LDPC code for a
transmission received
over a BSC channel
transition probability
q = 0.075. The
decoder halts after the
13th iteration when the
best guess violates no
parity checks. The final
decoding is error free.
54/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
LDPC codes
Error probability of the low-density parity-check code for the BSC with
q = 0.075, compared with algebraic codes. Squares: repetition codes and
Hamming (7,4) code. Crosses: BCH codes.
55/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
LDPC codes
Codes in wireless communication systems. In 5G, LDPC have been selected for
user data and polar codes for control data. In 4G, turbo codes were selected.
The advantage of LDPC is that the clock rate of the hardware does not have
to be increased with the increase of the code rate.
56/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Interleaving
Most of codes have been designed for
statistically independent errors (like in
BSC). In many channels however,
errors appear in a bursty way, like in
cellular communication system, or when
reading an optical support with
damaged surface.
A burst of errors of length b is a
sequence of b-bit errors where the first
and last are 1. An (n, k) linear block
code can correct bursts of length
b ≤ b 12 (n − k)c.
57/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Interleaving
The interleaver reorders the encoded data and transmits it over the channel. At
the receiver, the deinterleaver reorders the data and passes it to the decoder.
As a result, errors are spread out in time and appear independent. A block
interleaver of degree m, is formed by m rows and n columns...
58/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Interleaving
At the deinterleaver, symbols are stored in the matrix and read row-wise. As a
result, a burst of l = mb errors is broken into m bursts of length b.
Thus, an (n, k) code that can handle bursts of errors of length b can be
combined with an interleaver to create an interleaved (mn, mk) block code
that can handle bursts of length mb.
59/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Interleaving
For CD-ROM, this rate is too high so the standard of CD-ROM had added the
EDC (Error Detection Code) and ECC (Error Correction Code). This method
can make the error rate is less than 10−13 which satisfy the requirement of
CD-ROM.
60/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Concatenated codes
Although not optimal, decoding is usually done sequentially for each code.
61/62
Some algebra Linear block codes Decoding Probability of error Outstanding codes Interleaving Concatenation
Wrap up
Recommended bibliography:
S. Lin, D. J, Costello, Error Control Coding, Second edition, Prentice Hall, 2004
62/62