Lecture11 - Linear Block Codes
Lecture11 - Linear Block Codes
Chadi Abou-Rjeily
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Mathematical Preliminary: Hamming distance (1)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Mathematical Preliminary: Hamming distance (2)
dH (u, v ) = wH (u + v )
In fact, if ui 6= vi , then ui + vi = 1.
Example: Let u = [1 1 0 0 1] and v = [1 0 1 0 0]:
dH (u, v ) is given by:
dH (u, v ) = 0 + 1 + 1 + 0 + 1 = 3
wH (u + v ) = 3
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Introduction
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Block Codes (1)
Vn contains 2n elements.
Vn can be considered as a n-dimensional vector space over
{0, 1}.
Equivalent Definition: A (n, k) linear code is a k-dimensional
subspace of Vn .
For example, a plane is a 2-dimensional subspace of the
3-dimensional Euclidean space.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Linear Block Codes: Introduction (2)
In other words, it is possible to define a basis, and all the
codewords can be expressed as linear combinations of the
elements of this basis.
For example, in R3 , the xy-plane has degree 2 and a possible
choice of the basis corresponds to the two 3-dimensional
vectors u~ = (1, 0, 0) and ~
v = (0, 1, 0). Any vector of this plane
can be expressed in terms of this basis: (x, y , 0) = x u~ + y ~v
where x, y ∈ R.
Note that the basis is not unique.
For example, designate by {g1 , . . . , gk } the basis vectors
where each vector gi has a length n.
Each one of the 2k codewords can be expressed as a linear
combination of this basis.
In other words, the linear block encoding procedure associates
with every k-dimensional sequence u = (u1 , . . . , uk ) a
n-dimensional codeword v = (v1 , . . . , vn ) such that:
v = u1 g1 + u2 g2 + · · · + uk gk ; u1 , . . . , uk ∈ {0, 1}
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Generator matrix (1)
For a (n, k) linear block code we define the k × n generator
matrix G by:
g1 g1,1 g1,2 · · · g1,n
G = ... = ... .. ..
. ··· .
gk gk,1 gk,2 · · · gk,n
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Generator matrix (2)
In particular:
0 → 0G = 0 0 0 0 0
1 → 1G = 1 1 1 1 1
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Generator matrix (3)
For example, the generator matrix of the (3, 2) parity code is
given by:
1 0 1
G=
0 1 1
The sequence u = (u1 , u2 ) is encoded to the codeword
v = (v1 , v2 , v3 ) such that:
1 0 1
v = v1 v2 v3 = uG = u1 u2
0 1 1
= u1 u2 u1 + u2
In other words:
v1 = u1
v2 = u2
v3 = u1 + u2
where v3 is the parity-check redundant bit.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Generator matrix (4)
Consider the (5, 3) code whose generator matrix is given by:
1 1 1 0 0
G = 0 0 1 1 0
1 1 1 1 1
The information sequence u = (u1 , u2 , u3 ) is encoded to the
codeword v = (v1 , v2 , v3 , v4 , v5 ) such that:
1 1 1 0 0
v = uG = u1 u2 u3 0 0 1 1 0
1 1 1 1 1
= u1 + u3 , u1 + u3 , u1 + u2 + u3 , u2 + u3 , u3
In other words, the codebook is given by:
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Systematic encoding (3)
Every generator matrix can be written in a systematic form by
performing:
row reductions.
column reordering.
Example:
Consider the matrix G given by:
g1 1 1 1 0 0
G = g2 = 0 0 1 1 0
g3 1 1 1 1 1
Replacing the second row by g1 + g2 results in:
1 1 1 0 0
1 1 0 1 0
1 1 1 1 1
Replacing the third row by g2 + g3 and permuting the columns:
1 1 1 0 0 1 0 0 1 1
1 1 0 1 0 ⇔ 0 1 0 1 1
1 1 0 0 1 0 0 1 1 1
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Parity-check matrix (1)
cH T = 0n−k ; ∀c ∈ C
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Parity-check matrix (2)
Proposition: When G is written in a systematic form: G = [Ik P]
(with P being a k × (n − k) matrix), then H takes the form:
H = P T In−k
Proof:
GH T is given by:
T
GH T = Ik P PT In−k
P
= Ik P T
In−k
P
= Ik P
In−k
= Ik P + PIn−k
= P + P = 0k×(n−k)
The last equality follows since the addition is a modulo-2
addition (0 + 0 = 0 and 1 + 1 = 0).
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Parity-check matrix (3)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (1)
r =v +e
s = rH T = (v + e)H T = vH T + eH T = eH T
v̂ = r − e = r + e
s = rH T = eH T ⇒
h1,1 · · · hn−k,1
h1,2 · · · hn−k,2
s1 · · · sn−k = e1 e2 · · · en .. .. ..
. . .
h1,n · · · hn−k,n
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (3)
Consequently:
s1
= h1,1 e1 + h1,2 e2 + · · · + h1,n en
..
.
sn−k = hn−k,1 e1 + hn−k,2 e2 + · · · + hn−k,n en
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (4)
Proposition: The most probable error pattern is the one having
the smallest Hamming weight wH (e).
Proof:
The error vector is given by: e = (e1 , . . . , en ). Designating by
p ≤ 12 the parameter of the stationary and memoryless BSC
channel. Consequently:
p, ei = 1 (error) ;
p(ei ) = for i = 1, . . . , n
1 − p, ei = 0 (no error) .
Consequently:
n
Y
p(e) = p(ei )
i =1
= (1 − p)n−wH (e) p wH (e)
wH (e)
n p
= (1 − p)
1−p
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (5)
Note that:
The first equality follows since the n components of e are
independent (since the channel is memoryless).
The second equality follows since:
The number of 1’s in e (of probability p each) is equal to
wH (e).
The number of 0’s in e (of probability 1 − p each) is equal to
n − wH (e).
p
Given that p ≤ 21 , then 0 ≤ 1−p ≤ 1 implying that p(e) is a
decreasing function of wH (e).
Therefore, the most frequent non-zero error pattern is the
vector e such that wH (e) has the smallest non-zero value.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (6)
Example: Consider the (7, 4) Hamming code whose parity-check
matrix is given by:
0 1 1 1 1 0 0
H= 1 0 1 1 0 1 0
1 1 0 1 0 0 1
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (7)
The above system of equations admits 2k = 24 = 16 possible
solutions.
These solutions can be determined, for example, by varying
the values of e1 , e2 , e3 and e4 in {0, 1} and solving for e5 , e6
and e7 .
The solutions are given by:
[e1 e2 e3 e4 ] = [0 0 0 0] ⇒ [e5 e6 e7 ] = [1 0 1] ; wH (e) = 2
[e1 e2 e3 e4 ] = [0 0 0 1] ⇒ [e5 e6 e7 ] = [0 1 0] ; wH (e) = 2
[e1 e2 e3 e4 ] = [0 0 1 0] ⇒ [e5 e6 e7 ] = [0 1 1] ; wH (e) = 3
[e1 e2 e3 e4 ] = [0 0 1 1] ⇒ [e5 e6 e7 ] = [1 0 0] ; wH (e) = 3
[e1 e2 e3 e4 ] = [0 1 0 0] ⇒ [e5 e6 e7 ] = [0 0 0] ; wH (e) = 1
[e1 e2 e3 e4 ] = [0 1 0 1] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [0 1 1 0] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [0 1 1 1] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Syndrome decoding (8)
[e1 e2 e3 e4 ] = [1 0 0 0] ⇒ [e5 e6 e7 ] = [1 1 0] ; wH (e) = 3
[e1 e2 e3 e4 ] = [1 0 0 1] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [1 0 1 0] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [1 0 1 1] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [1 1 0 0] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [1 1 0 1] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [1 1 1 0] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
[e1 e2 e3 e4 ] = [1 1 1 1] ⇒ [e5 e6 e7 ] = [∗ ∗ ∗] ; wH (e) > 1
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Maximum-Likelihood Detection (4)
Example: Consider the (7, 4) Hamming code whose parity-check
matrix is given by:
0 1 1 1 1 0 0
H= 1 0 1 1 0 1
0
1 1 0 1 0 0 1
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Maximum-Likelihood Detection (5)
The 2k = 16 codewords as well as the distances between these
codewords and r are shown below:
c1 = [0 0 0 0 0 0 0] , dH (r , c1 ) = 3 ; c9 = [1000011] , dH (r , c9 ) = 2
c2 = [0 0 0 1 1 1 1] , dH (r , c2 ) = 3 ; c10 = [1001100] , dH (r , c10 ) = 2
c3 = [0 0 1 0 1 1 0] , dH (r , c3 ) = 2 ; c11 = [1010101] , dH (r , c11 ) = 3
c4 = [0 0 1 1 0 0 1] , dH (r , c4 ) = 6 ; c12 = [1011010] , dH (r , c12 ) = 3
c5 = [0 1 0 0 1 0 1] , dH (r , c5 ) = 4 ; c13 = [1100110] , dH (r , c13 ) = 1
c6 = [0 1 0 1 0 1 0] , dH (r , c6 ) = 4 ; c14 = [1101001] , dH (r , c14 ) = 5
c7 = [0 1 1 0 0 1 1] , dH (r , c7 ) = 5 ; c15 = [1110000] , dH (r , c15 ) = 4
c8 = [0 1 1 1 1 0 0] , dH (r , c8 ) = 5 ; c16 = [1111111] , dH (r , c16 ) = 4
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Minimum Distance of a code (1)
The minimum distance of a code is defined as:
dH (x, x ′ ) = wH (x + x ′ )
On the other hand, since the code is linear, then the sum of 2
codewords is also a codeword. In other words, x + x ′
corresponds to a codeword of C. Consequently:
1 0 0 0 1
There is no zero column. There are no 2, 3 or 4 columns of H
whose sum is equal to zero. The sum of the 5 columns of H is
equal to zero and dmin = 5.
Consider the (3, 2) parity-check code:
H= 1 1 1
There is no column that is equal to zero, then dmin > 1. The
sum of any two columns of H is equal to zero and dmin = 2.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Minimum Distance of a code (4)
Consequently, dmin = 3.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Detection (1)
Note that if the error pattern e is identical to a non-zero
codeword, then:
s = rH T = (v + e)H T = vH T + eH T = 0n−k + 0n−k = 0n−k
r =v +e ⇒ dH (r , v ) = wH (e)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Detection (3)
Note that even though such codes can not detect all error
patterns with dmin or more errors, they are capable of
detecting a large fraction of such errors.
In particular, we have previously proven that a (n, k) linear
code is capable of detecting a total number of error patterns
that is given by:
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Detection (4)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Detection (5)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Detection (6)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Detection (7)
A0 = 1 ; A1 = A2 = 0 ; A3 = A4 = 7 ; A5 = A6 = 0 ; A7 = 1
Consequently:
Pu = 7p 3 (1 − p)4 + 7p 4 (1 − p)3 + p 7
For p = 10−2 :
Pu ≃ 7 × 10−6
In other words, if 1 million codewords are transmitted over a
BSC with parameter p = 10−2 , on the average there are only
7 erroneous bit sequences passing through the decoder
without being detected.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Correction (1)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Correction (2)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Error Correction (4)
where the inequality follows from the fact that the block code
might correct some error patterns of t + 1 or more errors.
When p ≪ 1, the dominant term in the above summation is:
j d −1 k j d +1 k
n t+1 nk min +1 n k min
p = j
dmin −1 p 2
= j
dmin +1 p 2
t +1 2 +1 2
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Coding gain over AWGN channels (1)
Consider an AWGN channel where:
Y =X +Z
X is the transmitted signal having an energy E[X 2 ] = P.
Z stands for the AWGN noise having an energy E[Z 2 ] = N.
Y stands for the received signal.
The signal-to-noise ratio is defined as SNR = P/N.
The typical performance over AWGN channels is shown below:
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Coding gain over AWGN channels (2)
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes
Coding gain over AWGN channels (3)
It can be proven that at medium to high SNR, the coding
gain of a linear block code is given by:
10 log10 [Rc dmin ] dB
Note that Rc < 1: the simple redundancy results in a loss.
dmin > 1: the structure of the code results in a gain.
The product Rc dmin must be greater than 1 (to have a net
gain). In fact, the term Rc dmin must be maximized.
For example:
For the (7, 4) Hamming code, dmin = 3 and the coding gain is:
4
10 log10 [Rc dmin ] = 10 log10 3 ≈ 2.34 dB
7
For the (n, 1) repetition code, dmin = n and the coding gain is:
1
10 log10 [Rc dmin ] = 10 log10 n = 0 dB
n
In other words, there is no coding gain and repetition codes
are useless.
Chadi Abou-Rjeily Information and Coding Theory Lecture-11: Linear Block Codes