Chapter 11
Chapter 11
Chapter 11
Problem 11.2
The information in the message is
Problem 11.3
The entropy is
Problem 11.4
1
2 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
x1 0.7
y1
0.2
0.1
0.2
x2 0.5 y2
0.3
0.1
0.2
x3 y3
0.7
The entropy is
Problem 11.5
(a) The channel diagram is shown in Figure 11.1 (b) The output probabilities are
1 10
p (y1 ) = (0:7 + 0:2 + 0:1) = = 0:3333
3 30
1 9
p (y2 ) = (0:2 + 0:5 + 0:2) = = 0:3000
3 30
1 11
p (y3 ) = (0:1 + 0:3 + 0:7) = = 0:3667
3 30
11.1. PROBLEM SOLUTIONS 3
(c) Since
[P (Y )] = [P (X)] [P (Y jX)]
we can write
1
[P (X)] = [P (Y )] [P (Y jX)]
which is
2 3
1:6111 0:6667 0:0566
[P (X)] = [0:333 0:333 0:333] 4 0:6111 2:6667 1:0566 5
0:0566 0:6667 1:7222
This gives
[P (X)] = [0:3148 0:4444 0:2407]
(d) The joint probability matrix is
2 32 3
0:3148 0 0 0:7 0:2 0:1
[P (X; Y )] = 4 0 0:4444 0 5 4 0:2 0:5 0:3 5
0 0 0:2407 0:1 0:2 0:7
which gives 2 3
0:2204 0:0630 0:0315
[P (X; Y )] = 4 0:0889 0:2222 0:1333 5
0:0241 0:0481 0:1685
Note that the column sum gives the output probabilities [P (Y )], and the row sum gives
the input probabilities [P (X)] :
Problem 11.6
It was shown that the cascade of two BSCs is given has the channel matrix
1 1 (1 ) (1 )+ (1 ) + (1 )
=
1 1 (1 )+ (1 ) + (1 ) (1 )
which is (11.24) modi…ed so that the two channels are symmetric. It is clear that the
cascade of two BSCs is a BSC. Consider now three channels ABC, where A, B, and C are
binary symmetric. We have shown that the cascade of A and B, denoted (AB), is binary
symmetric. Therefore, the cascade of (AB) and C is binary symmetric. Continuing this
process illustrates that, by induction, that the cascade of an arbitrary number of BSCs is a
BSC.
Problem 11.7
4 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
For a noiseless channel, the transition probability matrix is a square matrix with 1s on the
main diagonal and zeros elsewhere. The joint probability matrix is a square matrix with
the input probabilities on the main diagonal and zeros elsewhere. In other words
2 3
p (x1 ) 0 0
6 0 p (x2 ) 0 7
6 7
[P (X; Y )] = 6 . . . . 7
.
4 . .
. . .
. . 5
0 0 p(xn )
Problem 11.8
0:995 0:005
A=
0:005 0:995
which corresponds to an error probability of 0:001, to increasing powers n and seeing where
the error probability reaches the critical value of 0:08. Consider the MATLAB program
Executing the program yields n 1 = 22. Thus we compute (MATLAB code is given)
a^22
ans =
0.9008 0.0992
0.0922 0.9008
a^23
ans =
0.8968 0.1032
0.1032 0.8968
Thus 22 cascaded channels meets the speci…cation for PE < 0:1. However cascading 23
channels yields PE > 0:1 and the speci…cation is not satis…ed. (Note: This may appear
11.1. PROBLEM SOLUTIONS 5
to be an impractical result since such a large number of cascaded channels are speci…ed.
However, the channel A may represent a lengthly cable with a large number of repeaters.
There are a variety of other practical examples.)
Problem 11.9
For the erasure channel we determine
where
2 X
X 3 2 X
X 3
p(yj jxi )p(xi )
H(XjY ) = p(xi ; yj ) log2 p(xi jyj ) = p(yj jxi )p(xi ) log2
p(yj )
i=1 j=1 i=1 j=1
p(y1 ) = (1 p)
p(y2 ) = p + (1 )p = p
p(y3 ) = (1 )(1 p)
Thus
(1 p) p
H(XjY ) = (1 p) log2 p log2
(1 p) p
(1 )p (1 )(1 p)
(1 )p log2 (1 )(1 p) log2
p (1 )(1 p)
This is
Since
H(X) = log2 ( ) (1 ) log2 (1 )
we have
I(X; Y ) = H(X) pH(X) = H(X)(1 p)
Therefore
C=1 p bits/symbol
and capacity is achieved for equally likely inputs.
Problem 11.10
6 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
3=4 1=4 0
P (Y ) = [ p(x1 p(x2 ) ] = [ 0:75p(x1 ) 0:25p(x1 ) p(x2 ) ]
0 0 1
For this problem note that H (XjY ) = 0 (each Y results from only one X) so that I (X; Y ) =
H (X). It therefore follows that
C = 1 bit/symbol
and that the capacity is achieved for
1
p (x1 ) = p (x2 ) =
2
Note that cascading this channel with a channel with 3 inputs and 2 outputs de…ned by
2 3
1 0
4 1 0 5
0 1
gives a channel with 2 inputs and 2 outputs having the channel matrix
2 3
1 0
3=4 1=4 0 4 1 0
1 0 5=
0 0 1 0 1
0 1
Problem 11.11
The cascade of the two channels has the channel matrix
1 p1 p1 1 p2 p 2 0
P (Y jX) =
p1 1 p1 0 p 2 1 p2
This gives
(1 p1 ) (1 p2 ) (1 p1 ) p2 + p1 p2 p1 (1 p2 )
P (Y jX) =
p1 (1 p2 ) p1 p2 + (1 p1 ) p2 (1 p1 ) (1 p2 )
Thus, the probability of y2 is independent of the input so that the cascade is a more general
erasure channel in that p(y1 jx2 ) and p(y3 jx1 ) are not zero. We will encounter a channel like
this when feedback channels are encountered in Section 11.6.3.
Problem 11.12
To show (10.30), write p (xi ; yj ) in (10.29) as p (xi jyj ) p (yj ) and recall that
Evaluating the resulting sum yields (10.30). The same method is used to show (10.31)
except that p (xi ; yj ) is written p (yj jxi ) p (xi ) :Problem 11.13
I (X; Y ) = H (Y ) H (Y jX)
where X
H (Y jxi ) = p (yj jxi ) log2 p (yj jxi )
j
C
2
p
0 1/2 1
We now show that equally likely outputs result if the inputs are equally likely. Assume
that p (xi ) = 41 for all i. Then
X
p (yj ) = p (xi ) p (yj jxi )
i
For each j
1X 1 1 1
p (yj ) = p (yj jxi ) = (p + q) = [p + (1 p)] =
4 4 4 4
i
so that
1
p (yj ) = ; all j
4
1
Since p (yj ) = 4 for all j, H (Y ) = 2, and the channel capacity is
C = 2 + p log2 p + (1 p) log2 (1 p)
or
C=2 H (p)
This is shown in Figure 11.2.
This channel is modeled as a pair of binary symmetric channels as shown. If p = 1 or
p = 0, each input uniquely determines the output and the channel reduces to a noiseless
channel with four inputs and four outputs. This gives a capacity of log2 4 = 2 bits/symbol.
If p = q = 12 , then each of the two subchannels (Channel 1 and Channel 2) have zero
capacity. However, x1 and x2 can be viewed as a single input and x3 and x4 can be viewed
11.1. PROBLEM SOLUTIONS 9
p
x
1 y
1
q
qq
Channel 1
x
2
p q y
2
x
3
p
q y
3
Channel 2 qq
p q
x
4 y
4
as a single input as shown in Figure 11.3. The result is equivalent to a noiseless channel
with two inputs and two outputs. This gives a capacity of log2 2 = 1 bit/symbol.
Note that this channel is an example of a general symmetric channel. The capacity of
such channels are easily computed. See Gallager (Information Theory and Reliable Com-
munications, Wiley, 1968, pages 91-94) for a discussion of these channels.
Problem 11.14
The entropy is maximized when each quantizing region occurs with probability 0:25. Thus
Z x1
1
ae ax dx = 1 e ax1 =
0 4
which gives
ax1 3
e =
4
or
1 4
x1 = ln = 0:2877=a
a 3
In a similar manner
Z x2
ax ax1 ax2 3 ax2 1
ae dx = e e = e =
x1 4 4
which gives
ax2 1
e =
2
10 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
or
1
x2 = ln (2) = 0:6931=a
a
Also Z x3
ax 1
ae dx =
x2 4
gives
x3 = 1:3863=a
Problem 11.15
The thresholds are now parameterized in terms of . We have
Z x1
r r2 =2 2 2 2 1
2
e dx = 1 e x1 = =
0 4
which gives
x21 3
2
= ln = ln(4=3)
4
Thus p
x1 = log(4=3) = 0:5364
For x2 we have
Z x2
r r 2 =2 2 x21 = 2 x22 = 2 3 x22 = 2 1
2
e dx = e e = e =
x1 4 2
so that p
x2 = ln(2) = 0:6931
Finally, for x3 we have
Z x3
r r2 =2 2 x22 = 2 x23 = 2 x22 = 2 3 1 1
2
e dx = e e =e = =
x2 4 4 2
so that p
x3 = ln(2) = 1:1774
As a check we compute
Z 1
r r2 =2 2 x23 = 2 (1:1774)2 1
2
e dx = e 0=e =
x3 4
Problem 11.16
First we compute the probabilities of the six messages. Using the Gaussian Q function
Z 1 Z 1
1 2 2 1 2 x
p e y =2 dy = p e y =2 dy = Q
2 x 2 x=
gives
Z Z 1
1 y 2 =2 2 1 1 y 2 =2
p (m3 ) = p e dy = p e dy = Q(0) Q (1) = 0:3413
2 0 2 2 = =1
Z 2
1 y 2 =2 2
p (m4 ) = p e dy = Q (1) Q (2) = 0:1359
2
Z 1
1 y 2 =2 2
p (m5 ) = p e dy = Q (2) Q(1) = Q(2) = 0:0214
2 2
By symmetry
H (X) = 2 [0:3413 log2 0:3413 + 0:1359 log2 0:1359 + 0:0228 log2 0:0228]
= 2:09 bits/symbol
Since the symbol (sample) rate is 500 samples/s, the information rate is
Problem 10.17 p
For BPSK, the error probability is Q 2z . From the data given
q
Uplink error probability = Q 2 108=10 = 0:000191
q
Downlink error probability = Q 2 105=10 = 0:0060
PE = 0:0062
Note that for all practical purposes the performance of the overall system is established by
the downlink performance.
Problem 11.18
The transition probabilities for the cascade of Channel 1 and Channel 2 are
It can be seen that the capacity of the cascade channel is less than the capacity of either
channel taken alone, which is to be expected since each channel causes errors and the error
probability on the cascade channel is greater than the error probability of either of the
individual channels.
Problem 11.19
Five thresholds are needed to de…ne the six quantization regions. The …ve thresholds are
k2 , k1 , 0, k1 , and k2 . The thresholds are selected so that the six quantization regions
are equally likely. For k1 we have
Z k1 Z 1
1 1 y 2 =2 2 1 1 y 2 =2 2 1 k1
=p e dy = p e dy = Q
6 2 0 2 2 k1 2
so that
k1 1 1 1
Q = =
2 6 3
inding the inverse Q-function yields
1 1 k1
Q = 0:4307 =
3
11.1. PROBLEM SOLUTIONS 13
For k2 we have Z 1
1 1 y 2 =2 2 k2
=p e dy = Q
6 2 k2
Taking the inverse Q function
1 1 k2
Q = 0:9674 =
6
and
k1 = 0:4307 and k2 = 0:9674
This gives the quantizing rule
Problem 11.20
The second way to determine the entropy of the fourth-order extension, is to determine the
probability distribution of the extended source. We have
81
1 symbol with probability
256
27
4 symbols with probability
256
9
6 symbols with probability
256
3
4 symbols with probability
256
1
1 symbol with probability
256
14 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
Thus
81 81 27 27 9 9
H X4 = log2 4 log2 6 log2
256 256 256 256 256 256
3 3 1 1
4 log2 log2
256 256 256 256
= 3:2451 bits/symbol
Problem 11.21
For the fourth-order extension we have
Source Symbol P () Codeword
AAAA 0.6561 0
BAAA 0.0729 100
ABAA 0.0729 101
AABA 0.0729 110
AAAB 0.0729 1110
AABB 0.0081 111100
ABAB 0.0081 1111010
BAAB 0.0081 1111011
ABBA 0.0081 1111100
BABA 0.0081 1111101
BBAA 0.0081 1111110
ABBB 0.0009 111111100
BABB 0.0009 111111101
BBAB 0.0009 111111110
BBBA 0.0009 1111111110
BBBB 0.0001 1111111111
The average wordlength: L = 1:9702 which is L=4 = 1:9702=4 = 0:4926. The e¢ ciencies
are given in the following table:
n L H (X n ) E¢ ciency
1 1 0.4690 46.90%
2 1.29 0.9380 72.71%
3 1.598 1.4070 88.05%
4 1.9702 1.8760 95.22%
Problem 11.22
11.1. PROBLEM SOLUTIONS 15
The entropy is
We know that
L
lim r 300
n!1 n
and that
L
lim = H (X)
n!1 n
Therefore, for n large
rH (X) 300
or
300 300
r =
H (X) 0:60984
which gives
r 491:932 symbols/s
Problem 11.23
The codewords for the Shannon-Fano and Hu¤man codes are summarized in the following
table:
Codewords
Source Symbol P ( ) Shannon-Fano Hu¤man
m1 0.40 00 1
m2 0.19 01 000
m3 0.16 10 001
m4 0.15 110 010
m5 0.10 111 011
The average wordlengths are:
Note that the Hu¤man code gives the shorter average wordlength and therefore the higher
e¢ ciency.
Problem 11.24
16 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
The entropy is
I = (0:2) (2 + 2 + 2 + 3 + 3) = 2:4
H (X) 2:319
= = 0:9675 = 96:75%
L 2:4
The diagram for determining the Hu¤man code is illustrated in Figure 11.4. This diagram
yields the codewords
m1 01
m2 10
m3 11
m4 000
m5 001
L = 0:2 (2 + 2 + 2 + 3 + 3) = 2:4
Since the average wordlength is the same as for the Shannon-Fano code, the e¢ ciency is
also the same.Problem 11.25
11.1. PROBLEM SOLUTIONS 17
0.6
0
1
0.4 0.4
0.4 0
m
1
1
m 0.2 0.2
m
12
0.2
0
m
1
m3
1
m 0.2
m
41
0.2
0
m
1
m
5
1
0.2
The Shannon-Fano and Hu¤man codes are as follows. (Note that the codes are not unique.)
Codewords
Source Symbol Shannon-Fano Hu¤man
m1 000 001
m2 001 010
m3 010 011
m4 011 100
m5 100 101
m6 101 110
m7 110 111
m8 1110 0000
m9 1111 0001
In both cases, there are seven codewords of length three and two codewords of length
four. Thus, both codes have the same average wordlengths and therefore have the same
e¢ ciencies. The average wordlength is
1 29
L= [7 (3) + 2 (4)] = = 3:2222
9 9
18 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
the e¢ ciency is
H (X)
E= = 98:38%
L
Problem 11.26
For the Shannon-Fano code we have
1 44
L= [4 (3) + 8 (4)] = = 3:6667
12 12
2/3 0
m
1
m
12
1/12 0
1/6 0
m
3 1/12 1
1/3 1/3 1
m
1
1/12 0
1m 4
1/6 1
m
5 1/12 1
m
16m
1/12 0
1/6 0
m
17 1/12 1
1/3 0
m
8 1/12 0
1/6 1
m
9
1/12 1
m
10
1/12 0
1/6 0
1/12 1
m
11
1/3 1
1/12 0
m
12
1/6 1
1/12 1
the codewords:
Source Symbol Codeword
m1 100
m2 101
m3 110
m4 111
m5 0000
m6 0001
m7 0010
m8 0011
m9 0100
m10 0101
m11 0110
m12 0111
As in the case of the Shannon-Fano code, we have four codewords of length three and eight
20 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
codewords of length four. The average wordlength is therefore 3:6667 and the e¢ ciency is
97:77%.
Problem 11.27
The source entropy is
H (X) = 0:35 log2 0:35 0:3 log2 0:3 0:2 log2 0:2 0:15 log2 0:15
= 1:9261 bits/source symbol
H X 2 = 2H (X) = 3:8522
The second-order extension source symbols are shown in the following table along with the
Shannon-Fano code.
Source Symbol P () Codeword
m1 m1 0.1225 000
m1 m2 0.1050 001
m2 m1 0.1050 010
m2 m2 0.0900 0110
m1 m3 0.0700 0111
m3 m1 0.0700 1000
m2 m3 0.0600 1001
m3 m2 0.0600 1010
m4 m1 0.0525 1011
m1 m4 0.0525 1100
m4 m2 0.0450 1101
m2 m4 0.0450 11100
m2 m2 0.0400 11101
m3 m4 0.0300 111100
m4 m3 0.0300 111101
m4 m4 0.0225 111110
for the last eight codewords. The average wordlength is 3.88000 and the e¢ ciency is
H X2 3:8522
E= = = 99:28%
L 3:88
which is a small improvement over the Shannon-Fano code.
Problem 11.28
The probability of message mk is
Z 0:1k
P (mk ) = 2x dx = 0:01 (2k 1)
0:1(k 1)
A source symbol rate of 250 symbols (samples) per second yields a binary symbol rate of
Problem 11.29
H (X) = 0:35 log2 0:35 0:3 log2 0:3 0:2 log2 0:2 0:15 log2 0:15
= 1:9261 bits/source symbol
H X 2 = 2H (X) = 3:8522
The second-order extension source symbols are shown in the following table. For a D = 3
alphabet we partition into sets of 3. The set of code symbols is (0; 1; 2).
H X2 3:8522
E= = = 90:02%
L log2 D (2:70) log2 3
Problem 11.30
The set of wordlengths from Table 10.3 is f1; 3; 3; 3; 5; 5; 5; 5g. The Kraft inequality gives
8
X 1 3 4
2li = 2 1
+3 2 3
+4 2 5
= + + =1
2 8 32
i=1
Problem 11.31
The Shannon-Hartley law with S = 50 and N = 10 5B gives
!
S 50 105
Cc = B log2 1+ = B log2 1+
N B
This is illustrated in the following …gure. It can be seen that as B ! 1 the capacity
approaches a …nite constant. For su¢ ciently small x, ln(1 + x) x. Therefore
50(105 )
lim Cc = = 7:2135 106
B!1 ln(2)
Problem 11.32
We now determine
!
4 P 105
Cc = 10 log2 1+ = 104 log2 (1 + 10P )
104
24 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
6
x 10
8
5
Capacity
0
2 4 6 8 10
10 10 10 10 10
Bandwidth - Hz
4
x 10
10
7
Capacity - bits/s
0
0 10 20 30 40 50 60 70 80 90 100
Signal Power - Watts
Cc 105 log2 (P )
and, therefore, Cc ! 1 as P ! 1.
Problem 11.33
For a rate 71 repetition code we have, assuming an error probability of q on a single trans-
mission,
7 4 7 5 7 6 7 7
PE = q (1 q)3 + q (1 q)2 + q (1 q) + q
4 5 6 7
which is
PE = 35q 4 (1 q)3 + 21q 5 (1 q)2 + 7q 6 (1 q) + q 7
1
For a rate 3 code we have the corresopnding result
PE = 3q 2 (1 q) + q 3
q = 0:0.01:0.1;
p7 = 35*(q.^4).*((1-q).^3)+21*(q.^5).*((1-q).^2)+7*(q.^6).*(1-q)+(q.^7);
p3 = 3*(1-q).*(q.^2)+(q.^3);
plot(q,p3,q,p7)
xlabel(’Error probability - q’)
ylabel(’Word error probability’)
are illustrated in Figure ??. The top curve (poorest performance) is for the rate 31 code and
the bottom curve is for the rate 17 repetition code. Note that these results are not typically
compariable since the values of p and q change as the code rate changes.
Problem 11.34
For a (8,7) parity-check code an odd number of errors can be detected but not corrected.
We therefore must compute the probablity of 1, 3, 5, or 7 errors in an 8-symbol sequence.
This is
8 8 3 8 5 8 7
PE = q (1 p)7 + q (1 q)5 + q (1 q)3 + q (1 q)
1 3 5 7
0.03
0.025
0.02
Word error probability
0.015
0.01
0.005
0
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
Error probability - q
Figure 11.8: Performance curves for rate 1/7 and rate 1/3 repetition codes.
28 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
Problem 11.35
Consider the ratio of the error probability of the coded system to the error probability of
the uncoded system for high SNR. Since we are considering z 1 we use the asympotic
approximation for the Gaussian Q function. Therefore, for the coded system
r ! r
2z 1 1 p n 1
( 2z=n)2 2z=n
qc = Q p p e = p e
n 2z=n 2 2z 2
s
qc 2z exp ( 2z=n) p 1
= = n exp 2z 1
qu 2z=n exp ( 2z) n
p
Note that for large n the ratio becomes nK, where K is a constant de…ned by exp(2z).
For …xed n, the loss in symbol error probability is therefore exponential with respect to the
SNR z, which is a greater loss than can be compensated by the error-correcting capability
p
of the repetition code. Note that for …xed z, the corresponding losss is proportional to n.
Problem 11.36
The parity-check matrix will have 15 11 = 4 rows and 15 columns. Since rows may be
permuted, the parity-check matrix is not unique. One possible selection is
2 3
0 0 0 0 1 1 1 1 1 1 1 1 0 0 0
6 0 1 1 1 0 0 0 1 1 1 1 0 1 0 0 7
[H] = 6
4 1
7
0 1 1 0 1 1 0 0 1 1 0 0 1 0 5
1 1 0 1 1 0 1 0 1 0 1 0 0 0 1
11.1. PROBLEM SOLUTIONS 29
where I11 is the 11 11 identity matrix and H11 represents the …rst 11 columns of the parity-
check matrix. From the structure of the parity-check matrix, we see that each parity symbol
is the sum of 7 information symbols. Since 7 is odd, the all-ones information sequence yields
the parity sequence 1111. This gives the codeword
[T ]t = [111111111111111]
A single error in the third position yields a syndrome which is the third column of the
parity-check matrix. Thus, for the assumed parity-check matrix, the syndrome is
2 3
0
6 1 7
[S] = 6
4 1 5
7
Problem 11.37
A possible parity-check matrix for a (15,11) Hamming code, which has 4 parity symbols, is
2 3
0 0 0 0 1 1 1 1 1 1 1 1 0 0 0
6 0 1 1 1 0 0 0 1 1 1 1 0 1 0 0 7
[H] = 6
4 1
7
0 1 1 0 1 1 0 0 1 1 0 0 1 0 5
1 1 0 1 1 0 1 0 1 0 1 0 0 0 1
30 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
Since columns of the parity-check matrix can be permuted, it is not unique, The form shown
is a systemantic code. Since each column is distinct, and there is no all-zeros column, there
are 15 distinct non-zero syndromes (columns) with each syndrome corresponding to a single
error in the position of that column. Thus, all single errors can be corrected and the code
is a distance 3 code.
Problem 11.38
The generrator matrix corresponding to the given parity-check matrix is
2 3
1 0 0 0
6 0 1 0 0 7
6 7
6 0 0 1 0 7
6 7
[G] = 6
6 0 0 0 1 7
7
6 0 1 1 1 7
6 7
4 1 0 1 1 5
1 1 0 1
2 3
c1 = a2 a3 a4
4 c2 = a1 a3 a4 5
c3 = a1 a2 a4
a1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
a2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
a3 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
a4 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
c1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1
c2 0 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1
c3 0 1 1 1 1 0 1 0 1 0 1 0 0 1 0 1
Problem 11.39
We …rst determine [Ti ] = [G] [Ai ] for i = 1; 2. The generator matrix for the previous problem
11.1. PROBLEM SOLUTIONS 31
Problem 11.40
For a Hamming code with r = n k parity check symbols, the wordlength n is
n = 2r 1
and
k = 2r r 1
32 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
The rate is
k 2r r 1
R= =
n 2r 1
If n is large, r is large. As r ! 1 both k and n approach 2r . Thus
2r
lim R = lim R = =1
n!1 r!1 2r
Problem 11.41
For a rate 13 repetition code
2
3
1
[G] = 4 1 5
1
1
and for a rate 5 repetition code
2 3
1
6 1 7
6 7
[G] = 6
6 1 7
7
4 1 5
1
1
The generator matrix for a rate n repetition code has one column and n rows. All elements
are unity.
Problem 11.42
The codeword is of the form (a1 a2 a3 a4 c1 c2 c3 ) where
c1 = a1 a2 a3
c2 = a2 a3 a4
c3 = a1 a2 a4
α
1 α
5
α
2 α
3 α
12 α
9 α
15 α
14 α
6
α
4 α
8 α
7 α
11 α
13 α
16 α
10
Using the generator matrix, we can determine the codewords. The codewords are (read
vertically)
a1 0 1 1 1 1 0 0 0 1 1 1 0 0 0 0 1
a2 0 0 1 1 1 0 0 1 0 1 0 1 1 0 1 0
a3 0 0 0 1 1 0 1 1 1 0 0 1 0 1 0 1
a4 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 0
c1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 0
c2 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1
c3 0 1 0 0 1 1 1 0 0 1 0 1 1 0 0 1
Let i denote the i-th code word and let i ! j indicate that a cyclic shift of i yields
j The cyclic shifts are illustrated in Figure 11.9.
.
Problem 11.43
The parity-check matrix for the coder in the previous problem is
2 3
1 1 1 0 1 0 0
[H] = 4 0 1 1 1 0 1 0 5
1 1 0 1 0 0 1
For the received sequence
[R]t = [1101001]
the syndrome is 3 2
0
[S] = [H] [R] = 4 0 5
0
34 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
This indicates no errors, which is in agreement with Figure 11.15. For the received sequence
[R]t = [1101011]
the syndrome is 32
0
[S] = [H] [R] = 4 1 5
0
This syndrome indicates an error in the 6th position. Thus the assumed transmitted code-
word is
[T ]t = [1101001]
which is also in agreement with Figure 11.15.
Problem 11.44
The parity-check matrix for a (7; 4) Hamming code, as we have de…ned a Hamming code, is
a code in which the ith column of the parity matrix is the binary representation of i. This
gives 2 3
0 0 0 1 1 1 1
[H] = 4 0 1 1 0 0 1 1 5
1 0 1 0 1 0 1
The parity checks are in positions 1,2, and 4. Moving the parity checks to positions 5, 6,
and 7 yields a systematic code with the generator matrix
2 3
1 0 0 0
6 0 1 0 0 7
6 7
6 0 0 1 0 7
6 7
[G] = 6
6 0 0 0 1 7
7
6 0 1 1 1 7
6 7
4 1 0 1 1 5
1 1 0 1
Note that all columns of [H] are still distinct and therefore all single errors are corrected.
Thus, the distance three property is preserved. Since the …rst four columns of [H] can be
in any order, there are 4! = 24 di¤erent (7; 4) systematic codes. If the code is not required
11.1. PROBLEM SOLUTIONS 35
to be systematic, there are 7! = 5040 di¤erent codes, all of which will have equivalent
performance in an AWGN channel.
Problem 11.45
The probability of two errors in a 7 symbol codeword is
7
P f2 errorsg = (1 qc )5 qc2 = 21qc2 (1 qc )5
2
and the probability of three errors in a 7 symbol codeword is
7
P f3 errorsg = (1 qc )4 qc3 = 35qc3 (1 qc )4
3
The ratio of P f3 errorsg to P f2 errorsg is
Pr f3 errorsg 35qc3 (1 qc )4 5 qc
R= = 5 = 3 1
Pr f2 errorsg 21qc2 (1 qc ) qc
We now determine the coded error probability qc . Since BPSK modulation is used
r !
2z
qc = Q
7
Problem 11.46
For the convolutional coder shown in Figure 11.24 we have the three outputs
v1 = s1 s2 s3
v2 = s1
v2 = s1 s2
36 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
v1 = 0 s1 s2 = 0 a
v2 = 0
v3 = 0 s1
v1 = 1 s1 s2 = 1 a
v2 = 1
v3 = 1 s1
Problem 11.47
For the convolutional coder shown in Figure 11.24 we have the three outputs
v1 = s1 s2 s3 s4
v2 = s1 s2 s4
v1 = 0 s1 s2 s3 = 0 a
v2 = 0 s1 s3 = 0 b
v1 = 1 s1 s2 s3 = 1 a
v2 = 1 s1 s3 = 1 b
Problem 11.48
For the encoder shown, the constraint span is k = 4. We …rst need to compute the states
for the encoder. The output is v1 v2 where v1 = s1 s2 s3 s4 and v2 = s1 s2 s4 .
11.1. PROBLEM SOLUTIONS 37
We now compute the state transitions and the output using the state diagram shown in
Figure 11.10. This gives the following table.
Previous Current
State s1 s2 s2 Input s1 s2 s3 s4 State Output
A 000 0 0000 A 00
1 1000 E 11
B 001 0 0001 A 11
1 1001 E 00
C 010 0 0010 B 10
1 1010 F 01
D 011 0 0011 B 01
1 1011 F 10
E 100 0 0100 C 11
1 1100 G 00
F 101 0 0101 C 00
1 1101 G 11
G 110 0 0110 D 01
1 1110 H 10
H 111 0 0111 D 10
1 1111 H 01
Problem 11.49
For the encoder shown, we have v1 = s1 s2 s3 and v2 = s1 s3 . The trellis diagram
is illustrated in Figure 11.11. The state transitions, and the output corresponding to each
transition appears in the following table.
State s1 s2 Input s1 s2 s3 State Output
A 00 0 000 A 00
1 100 C 11
B 01 0 001 A 11
1 101 C 00
C 10 0 010 B 10
1 110 D 01
D 11 0 011 B 01
1 111 D 10
Problem 11.50
The source rate is rs = 5000 symbols/second. The channel symbol rate is
n n
rc = rs = 5000
k k
38 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
(0 0)
(1 1)
(1 1)
(1 0)
C
B (0 1) (1 1)
(0 0) E
(0 1)
(0 0) (0 0)
D (0 1)
(1 0)
(1 1)
G
F
(1 0)
(1 0)
H
(0 1)
(00)
(10) (10)
(10)
(10)
Steady-State Termination
Transitions
will exceed 1000 by only a small amount. We therefore try a (1023,1013) Hamming code
having n k = 10 parity symbols. (See problem 10.41.) The number of symbols a¤ected
by the burst is
1023
m = 1000 = 1009:9
1013
Since m must be an integer lower bounded by 1009.9, we let m = 1010. The full interleaving
array contains mn symbols, since m may be received in error (worst case) m(n 1) must
be received correctly. Since the symbol rate on the channel is 5000n=k this gives a required
error-free span of
m(n 1) 1010 1022
= = 204:43 s
5000n=k 5000 1023=1013
This is probably not very practical but it illustrates the process and the problem of using
long codes with low error-correcting capabilities for interleaving.
Problem 11.51
40 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
n 23
rc = rs = 5000
k 12
n 23
rc T b = rs T b = 5000Tb
k 12
channel symbols can be a¤ected by the burst. The burst can a¤ect 3 columns, containing
3m symbols, of the interleaving table. Assuming that Tb = 0:2 s, the burst length, expressed
in symbols, is
23
3m = rc Tb = (5000) (0:2) = 1916:7 symbols
12
Thus
1916:7
m= = 638:89
3
We therefore set m = 639, which gives an interleaving array with 639 rows and 23 columns.
Since 3 columns can contain errors we must have 20 error-free columns representing 20(639)
symbols. This represents an error-free span of
20m 20(639)
= = 1:3336 s
rc 5000(23=12)
We see that the more powerful code results in a much shorter required error-free span and
a smaller interleaving array.
Problem 11.52
The probability of n transmissions is the probability of n 1 retransmissions. This is P2n 1
.
The expected value of N is therefore
(1 )
X
n 1
E nP2
n=1
From
1
X 1
xn = ; jxj < 1
1 x
n=0
we can obtain, by di¤erentiating both sides of the above wrt x,
1
X 1
nxn 1
=
(1 x)2
n=1
11.2. COMPUTER EXERCISES 41
Problem 11.53
The required plot is shown in Figure 11.12.
For two messages the problem is easy since there is only a single independent probability.
The MATLAB program follows
% File: ce11_1a.m
a = 0.001:0.001:0.999;
b =1-a;
lna = length(a);
H = zeros(1,lna);
H=-(a.*log(a)+b.*log(b))/log(2);
plot(a,H);
xlabel(’a’)
ylabel(’Entropy’)
% File: ce11_1b.m
n = 50; % number of points in vector
nn = n+1; % increment for zero
H = zeros(nn,nn); % initialize entropy array
z = (0:n)/n; % probability vector
z(1) = eps; % prevent problems with log(0)
for i=1:nn
for j=1:nn
c = 1-z(i)-z(j); % calculate third probability
if c>0
xx = [z(i) z(j) c];
H(i,j)= -xx*log(xx)’/log(2); % compute entropy
end
end
end
colormap([0 0 0]) % b&w colormap for mesh
mesh(z,z,H); % plot entropy
view(-45,30); % set view angle
xlabel(’Probability of message a’)
ylabel(’Probability of message b’)
zlabel(’Entropy’)
figure % new figure
11.2. COMPUTER EXERCISES 43
The resulting plot is illustrated in Figure ??. One should experiment with various viewing
locations.
Next we draw a countour map with 10 countour lines. The result is illustrated in Figure
10.17. Note the peak at 0.33, 0.33, indicating that the maximum entropy occurs when all
three source messages occur with equal probability
% File: ce11_2.m
clear all
msgprobs = input(’Enter message probabilities as a vector, ...
e.g., [0.5 0.25 0.25] > ’);
ext = input(’Enter desired extension (1 if no extension is desired) > ’);
entp = -sum(msgprobs.*log(msgprobs))/log(2); % original source entropy
dispa = [’The source entropy is ’, ...
num2str(entp,’%15.5f’),’ bits/symbol.’]; disp(dispa)
%
% Determine probabilities and entropy of extended source.
%
if ext>1
1
This book is highly recommended as a supplemental text in basic communications courses. We have
found it useful as a resource for in-class demonstrations and for homework assignments extending material
covered in class.
This particular computer example, as originally developed by Proakis, Salehi, and Bauch, provides an
excellent example of several MATLAB programming techniques. It has been said that a key to understanding
e¢ cient MATLAB programming techniques is to understand the use of the colon and the find command.
This program makes e¢ cient use of both.
44 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
We will use the preceding MATLAB program to work Problem 11.28. The MATLAB
dialog follows.
» ce11_2.m
Enter message probabilities as a vector, ...
e.g., [0.5 0.25 0.25] > [0.35 0.3 0.2 0.15]
The source entropy is 1.92612 bits/symbol.
Enter desired extension (1 if no extension is desired) > 2
The extended source entropy is 3.85224 bits/symbol.
codewords =
100
001
1011
0001
010
1111
0111
11100
1100
1010
11011
00001
0110
11101
11010
00000
46 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
% File: ce11_3.m
zdB = 0:30;
z = 10.^(zdB/10);
qa = 0.5*exp(-0.5*z);
qa3 = 0.5*exp(-0.5*z/3);
qa7 = 0.5*exp(-0.5*z/7);
pa7 = 35*((1-qa7).^3).*(qa7.^4)+21*((1-qa7).^2).*(qa7.^5)...
+7*(1-qa7).*(qa7.^6)+(qa7.^7);
pa3 = 3*(1-qa3).*(qa3.^2)+(qa3.^3);
qr = 0.5./(1+z/2);
qr3 = 0.5./(1+z/(2*3));
qr7 = 0.5./(1+z/(2*7));
pr7 = 35*((1-qr7).^3).*(qr7.^4)+21*((1-qr7).^2).*(qr7.^5)...
+7*(1-qr7).*(qr7.^6)+(qr7.^7);
pr3 = 3*(1-qr3).*(qr3.^2)+(qr3.^3);
semilogy(zdB,qr,zdB,pr3,zdB,pr7,zdB,qa,zdB,pa3,zdB,pa7)
axis([0 30 0.0001 1])
xlabel(’Signal-to-Noise Ratio, z - dB’)
ylabel(’Probability ’)
Executing the code yields the results illustrated in Figure ?? in the text. The curves can
be identi…ed from Figure 10.18 in the text.
% File: ce11_4a.m
zdB = 0:0.5:10; % set Eb/No in dB
z = 10.^(zdB/10); % convert to linear scale
ber1 = q(sqrt(4*2*z/7)); % SER for (7,4) BCH code
ber2 = q(sqrt(7*2*z/15)); % SER for (15,7) BCH code
ber3 = q(sqrt(16*2*z/31)); % SER for (31,16) BCH code
ber4 = q(sqrt(30*2*z/63)); % SER for (63,30) BCH code
11.2. COMPUTER EXERCISES 47
Executing the code for the rate 0.5 code yields the results shown in Figure 11.13. For SNRs
exceeding 5 dB, the order of the plots is in order of word length n, with n = being the top
curve (least error correcting capability) and n = 63 being the bottom curve (greatest error
correcting capability).
For the rate 0.75 BCH codes, we use the following MATLAB program.
% File: ce11_4b.m
zdB = 0:0.5:10; % set Eb/No in dB
z = 10.^(zdB/10); % convert to linear scale
ber1 = q(sqrt(11*2*z/15)); % SER for (15,11) BCH code
ber2 = q(sqrt(21*2*z/31)); % SER for (31,21) BCH code
ber3 = q(sqrt(45*2*z/63)); % SER for (63,45) BCH code
ber4 = q(sqrt(99*2*z/127)); % SER for (127,99) BCH code
berbch1 = ser2ber(2,15,3,1,ber1); % BER for (15,11) BCH code
berbch2 = ser2ber(2,31,5,2,ber2); % BER for (31,21) BCH code
berbch3 = ser2ber(2,63,7,3,ber3); % BER for (63,45) BCH code
berbch4 = ser2ber(2,127,9,4,ber4); % BER for (127,99) BCH code
semilogy(zdB,berbch1,zdB,berbch2,zdB,berbch3,zdB,berbch4)
xlabel(’E_b/N_o in dB’) % label x axis
ylabel(’Bit Error Probability’) % label y axis
% End of script file.
Executing the code for the rate 0.75 code yields the results shown in Figure 11.14. For SNRs
exceeding 5 dB, the order of the plots is in order of word length n, with n = 15 being the
top curve (least error correcting capability) and n = 127 being the bottom curve (greatest
error correcting capability).
0
10
-2
10
-4
10
Bit Error Probability
-6
10
-8
10
-10
10
-12
10
-14
10
0 1 2 3 4 5 6 7 8 9 10
Eb/No in dB
Figure 11.13: Rate 1/2 BCH code results for Computer Exercise 11.4.
11.2. COMPUTER EXERCISES 49
0
10
-5
10
Bit Error Probability
-10
10
-15
10
0 1 2 3 4 5 6 7 8 9 10
Eb/No in dB
Figure 11.14: Rate 3/4 BCH code results for Computer Exercise 11.4.
50 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
» nchoosek(1000,500)
Warning: Result may not be exact.
> In C:nMATLABR11ntoolboxnmatlabnspecfunnnchoosek.m at line 50
ans =
2.7029e+299
The warning indicates a possible with numerical percision. A possible way to mitigate this
is to perform the calculation using logarithms as illustrated in the function below.
%File: nkchoose.m
Function out=nkchoose(n,k)
% Computes n!/k!/(n-k)!
a = sum(log(1:n)); % ln of n!
b = sum(log(1:k)); % ln of k!
c = sum(log(1:(n-k))); % ln of (n-k)!
out = round(exp(a-b-c)); % result
% End of function file.
The main program for evaluating the performance of the (511,385) BCH code is shown
below.
% File: ce11_5.m
zdB = 0:0.5:10; % set Eb/No in dB
z = 10.^(zdB/10); % convert to linear scale
ber1 = q(sqrt(z)); % FSK result
ber2 = q(sqrt(385*z/511)); % SER for (511,385) BCH code
ber3 = q(sqrt(768*z/1023)); % SER for (1023,768) BCH code
berbch1 = ser2ber1(2,511,29,14,ber2); % BER for (511,385) BCH code
berbch2 = ser2ber1(2,1023,53,26,ber3); % BER for (1023,768) BCH code
semilogy(zdB,ber1,’k-’,zdB,berbch1,’k--’,zdB,berbch2,’k-.’)
xlabel(’E_b/N_o in dB’) % label x axis
ylabel(’Bit Error Probability’) % label y axis
legend(’Uncoded’,’(511,385) BCH code’,’(1023,768) BCH code’,3)
% End of script file.
Note that this program calls ser2ber1 rather than ser2ber. In order to evaluate the
performance of the (1023,768) BCH code, it is necessay to modify the routine for mapping
the code symbol error rate so that the calculation is performed using logarithms as the
following MATLAB code indicates.
% File: ser2ber1.m
11.2. COMPUTER EXERCISES 51
% File: ce11_6.m
clear all
invector = input(’Enter input sequence as a vector (in brackets with spaces)
> ’);
d = [’The input sequence is ’,num2str(invector),’.’];
disp(d)
sr = [0 0 0];
for k=1:4
sr = [invector(1,k) sr(1,1) sr(1,2)];
v1 = dec2bin(rem(sr(1,1)+sr(1,2)+sr(1,3),2));
52 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
0
10
-5
10
Bit Error Probability
-10
10
-15
10
Uncoded
(511,385) BCH code
(1023,768) BCH code
-20
10
0 1 2 3 4 5 6 7 8 9 10
Eb/No in dB
v2 = dec2bin(sr(1,1));
v3 = dec2bin(rem(sr(1,1)+sr(1,2),2));
c = [v1 v2 v3];
out(1,k) = bin2dec(c);
end
out = dec2bin(out)
% End of script file.
The program is illustrated by generating the outputs for the path labeled ’A’ in Figure
11.25., for which the input bit stream is 1010. The MATLAB dialog is as follows:
» ce11_6
Enter input sequence as a vector (in brackets with spaces) > [1 0 1 0]
The input sequence is 1 0 1 0.
out =
111
101
011
101
The four outputs are represented as the rows following ‘out’in the preceding dialog. This
corresponds to the sequence 111 101 011 101, which is Path A as shown in Figure 11.25 in
the text. (Note: If all outputs are 0, the sequence 000 is represented by a single 0.)
% File: ce11_7.m
g = [0.1 0.3]; % gamma
zdB = 0:0.1:10; % z in dB
z = 10.^(zdB/10); % vector of z values
qt = Q(sqrt(2*z)); % gamma=0 case
for k=1:2
q1 = Q((1-g(k))*sqrt(2*z));
q2 = Q((1+g(k))*sqrt(2*z));
p2 = q1-q2; % P2
p1 = q2; % P1
pe(k,:) = p1./(1-p2); % probability of error
54 CHAPTER 11. SOURCE CODING AND ERROR CORRECTION TECHNIQUES
N(k,:) = 1./((1-p2).*(1-p2));
end
subplot(2,2,1)
semilogy(zdB,pe(1,:),zdB,qt)
title(’gamma = 0.1’)
xlabel(’z - dB’); ylabel(’Error Probability’); grid
subplot(2,2,2)
semilogy(zdB,pe(2,:),zdB,qt)
title(’gamma = 0.3’)
xlabel(’z - dB’); ylabel(’Error Probability’); grid
subplot(2,2,3)
plot(zdB,N(1,:))
xlabel(’z - dB’); ylabel(’Ave. Transmissions/Symbol’);
axis([0 10 1 1.4]); grid
subplot(2,2,4)
plot(zdB,N(2,:))
xlabel(’z - dB’); ylabel(’Ave. Transmissions/Symbol’);
axis([0 10 1 1.4]); grid
% End of script file.
Executing the program gives the results shown in Figure 11.16. As expected, as is in-
creased, the error probability deceases at the cost of an increase in the average number
of transmissions. The key, however, is that increased performance is achieved with only a
moderate increase in the rate of retransmissions. This is especially true at higher SNRs.
11.2. COMPUTER EXERCISES 55
0
gamma = 0.1 0
gamma = 0.3
10 10
Error Probability
Error Probability
-5 -5
10 10
-10 -10
10 10
0 5 10 0 5 10
z - dB z - dB
Ave. Transmissions/Symbol
Ave. Transmissions/Symbol
1.4 1.4
1.3 1.3
1.2 1.2
1.1 1.1
1 1
0 5 10 0 5 10
z - dB z - dB