Вы находитесь на странице: 1из 14

EE 561: Communication Theory Spring 2007 Homework #4

date assigned: Sat., Apr. 14, 2007


date due: Tue., Apr. 24, 2007 1. An (8,4) two-dimensional binary product code can created using the following set of equations: ci = xi for 1 i 4 c1 = x1 c2 = x2 c5 = x1 x2 c5 = x1 x2 c3 = x3 c4 = x4 c6 = x3 x4 c6 = x3 x4 c7 = x1 x3 c8 = x2 x4 c7 = x1 x3 c8 = x2 x4 Where x = [x1, x2, x3, x4] is the encoder input and c = [c1, , c8] is the encoder output. a) Is this code systematic? Is it cyclic? Yes, the code is systematic since c1 c4 are the data bits x1 x4..

The codewords can be found using the following MATLAB code.


% Given (n,k) = (8,4) n = 8; k = 4; % x = [x1,x2,x3,x4] % Find all possible inputs and store in matrix x_dec = [0:1:2^k-1]; x = mod(dec2base(x_dec,2),2) % c = [c1,...,c8] % c1->c4 = x1->x4 % c5 = x1$x2, c6 = x3&x4, c7 = x1&x3, c8 = x2&x4 c5 = mod(x(1:16,1) + x(1:16,2),2); c6 = mod(x(1:16,3) + x(1:16,4),2); c7 = mod(x(1:16,1) + x(1:16,3),2); c8 = mod(x(1:16,2) + x(1:16,4),2); % Store codeword matrix c = [x c5 c6 c7 c8]

The codeword matrix is then:


c= 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 1 0

1 1 1 1 1

0 1 1 1 1

1 0 0 1 1

1 0 1 0 1

1 0 0 0 0

0 0 1 1 0

0 1 1 0 0

1 1 0 1 0

To determine whether this code is cyclic or not, look at c1 = [00010101]. If the bits in this codeword are shifted once to the left, the sequence becomes [00101010]. By examining c, it can be seen that this shifted codeword is not a valid codeword. Therefore, the code is not cyclic. b) Find the minimum distance dmin and error correcting capability t of this code. The code is linear. This can be found, for instance, by verifying that the modulo-2 sum of any pair of codewords is a codeword. For linear codes, the minimum distance is the smallest Hamming weight of any nonzero codeword. The following MATLAB code was used in conjunction with the code given in part a to calculate the minimum Hamming weight of this code.
% Determine the Hamming weight of the codewords w = sum(c,2); % Find the minimum Hamming weight (excluding the nonzero codeword) w_min = min(w(2:16)) w_min = 3

Therefore, dmin = 3 Note that every message of weight one will produce a codeword of weight 3. The error correcting capability was found using the following MATLAB code in conjunction with the previous code.
% Find the error correcting capability t = floor((w_min - 1) / 2)

t= 1

Therefore, this code has an error correction capability of 1 error. c) Find the generator (G) and parity check (H) matrices for this code. Since the code was determined to be systematic in part a, the generator matrix G has the form G = [Ik : P] where Ik is a k by k identity matrix. The generator matrix can be partitioned into a 4x4 identity matrix and a 4x4 matrix found using the given set of equations (e.g. column 1 of the parity matrix is [1 1 0 0]T since c5 is given by x1$x2).

1 1 P= 0 0 1 0 G= 0 0

0 0 1 1 0 1 0 0

1 0 1 0 0 0 1 0

0 1 0 1 0 0 0 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 0 1

Since the code is systematic, H = [PT : In-k]

1 0 PT = 1 0 1 0 H = 1 0

1 0 0 1 1 0 0 1

0 1 1 0 0 1 1 0

0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

d) Determine the weight distributions of this code, d and ad for 0d8. The following MATLAB code was used in conjunction with the code from parts a and b to help determine the weight distributions.
% Find a_d [a_d d] = hist(w,0:1:n) % Create a sorted matrix of Hamming and information weights d_sum = sortrows([w sum(x,2)],1)

MATLAB returns:
a_d = 1 d= 0 1 2 3 4 5 6 7 8 0 0 4 5 4 2 0 0

d_sum = 0 3 3 3 3 4 4 4 4 4 5 5 5 5 6 6 0 1 1 1 1 2 2 2 2 4 3 3 3 3 2 2

The number of codewords of weight d is given by the vector a_d. The total information weight of all codewords of weight d is given indirectly by the matrix d_sum. By inspection, the total information weight of codewords of weight 0 is 0, the total information weight of codewords of weight 3 is 1+1+1+1 =4, etc. These results are summarized in the following table.

d 0 1 2 3 4 5 6 7 8

ad 1 0 0 4 5 4 2 0 0

d 0 0 0 4 12 12 4 0 0

e) Find an expression for the codeword and bit error probability when hard-decision decoding is used. The expression should be a function of p, the probability that a coded bit is in error. Note: this code is not perfect; therefore, the codeword and bit error probability expressions will be in the form of an inequality. Codeword error probability (hard-decision decoding)

Pc

i = t +1

i p (1 p )
n

n i

t n n i = 1 p i (1 p ) i =0 i

Substituting the values gives


1 8 8i 8 7 Pc 1 p i (1 p ) = 1 (1 p ) 8 p (1 p ) i =0 i

Pc 1 (1 p ) 8 p (1 p )
8

The bit error probability with hard-decision decoding is given by the approximation: (t + 1) Pb Pc k where (t+1) is the average number of bit errors that occurs when t+1 code bits are in error. When there are t+1 code bit errors, the decoder will incorrectly select one of the codewords at distance dmin from the transmitted codeword. Since each of the four codewords of weight dmin = 3 have an information weight of 1, we can conclude that (t+1)=1. and therefore Pb = Pc/4.

f) Find an expression for the codeword and bit error probability when BPSK modulation is used along with soft-decision decoding. The expression should be a function of Eb/No. Codeword error probability (soft-decision decoding)

Pc

2rd b ad Q N d = d min o
n

Substituting values for dmin, n, k and r = k/n = yields


8 db Pc ad Q N d =3 o

5 b + 4Q N o 6 b + 2Q N o

Expanding the summation and substituting the values of ad gives

3 b Pc 4Q N o

4 b + 5Q N o

Bit error probability (soft-decision decoding)

Pb

d = d min

2rd b Q k No

Substituting values for dmin, n, k and r = k/n = yields

Pb
d =3

db Q 4 No

Expanding the summation and substituting the values of d gives

3 b Pb Q N o

4 b + 3Q N o

5 b + 3Q N o

6 b + Q N o

2. On the same plot, show the following as a function of Eb/No = 0 to 10 dB: a) The bit error probability of a (255,207) BCH code with hard decision decoding and BPSK modulation. Since we dont know the distance spectrum, assume that Pb dminPc/n. From Table 6-11, t = 6 for a (255,207) BCH code. The error correcting capability is related to the minimum distance by

d 1 t = min 2
Rearranging and solving for dmin yields

d min = 2t + 1 = 13

The codeword error probability is (hard-decision decoding)

Pc

t n i n n i n i p (1 p ) = 1 p i (1 p ) 1 i i =t + i =0 i n

Substituting the values of n and t gives


6 255 i 255i Pc 1 p (1 p ) i =0 i

For BPSK modulation,

2r b p = Q N o

Substituting the value of r = k/n into this expression gives

138 b p = Q 85 N o
Substituting this expression into the codeword error probability inequality gives
i

255 138 b Pc 1 Q 85 N i =0 i o
6

138 b 1 Q 85 N o

255i

Taking into account the assumption that Pb dmin Pc / n yields


255 i i 6 138 b 255 138 b 13 Pb 1 Q Q 1 85 N 255 i =0 i 85 N o o

b) The bit error probability of a (255,99) BCH code with hard decision decoding and BPSK modulation. Again, assume that Pb dminPc/n. From Table 6-11, t = 23 for a (255,99) BCH code. Solving for dmin yields

d min = 2t + 1 = 47 2r b p = Q N o

For BPSK modulation,

Substituting the value of r = k/n into this expression gives

66 b p = Q 85 N o
Substituting this expression into the codeword error probability inequality gives
i

255 66 b Pc 1 Q 85 N i =0 i o
23

66 b 1 Q 85 N o

255 i

Taking into account the assumption that Pb dmin Pc / n yields


255 i i 23 255 66 b 66 b 47 Pb 1 Q Q 1 85 N 255 i =0 i 85 N o o

c) The bit error probability of BPSK signaling with no error correction coding. What is the coding gain of the (255,207) BCH code and the (255,99) BCH code with respect to uncoded BPSK modulation at Pb =10-5? How far from the unconstrained input channel capacity are the two BCH codes at Pb =10-5? The bit error probability of uncoded BPSK is

2 b Pb = Q N o

The unconstrained input capacity (in dB) at a rate R is

Eb 22 R 1 in dB = 10 log10 No 2R

The plot of the bit error probabilities of BCH codes with BPSK modulation and the bit error probability of uncoded BPSK is shown next

The coding gains (in dB) of the (255,207) BCH code and the (255,99) BCH code with respect to uncoded BPSK modulation at Pb =10-5were found using MATLAB Coding gain (in dB) of (255,207) BCH code
coding_gain_a = 3.3700

Coding gain (in dB) of (255,99) BCH code


coding_gain_b = 3.5200

The distances (in dB) of the (255,207) BCH code and the (255,99) BCH code from the unconstrained input channel capacity of the two BCH codes at Pb =10-5 were found using MATLAB Distance (in dB) of the (255,207) BCH code from the unconstrained input channel capacity
dist_from_capacity_a = 5.1413

Distance (in dB) of the (255,99) BCH code from the unconstrained input channel capacity
dist_from_capacity_b = 6.4407

The MATLAB code used to plot the figure and to solve for the coding gains and distances from capacity is given next
% Define SNR vector in dBs EbNodB = 0:0.01:10; % Convert SNR from dBs to linear units EbNo = 10 .^ (EbNodB / 10); % Define BCH_a code parameters n_a = 255; k_a = 207; t_a = 6; % Define BCH_b code parameters n_b = 255; k_b = 99; t_b = 23; % Calculate the rates r_a = k_a / n_a; r_b = k_b / n_b; % Calculate the minimum distances dmin_a = 2 * t_a + 1; dmin_b = 2 * t_b + 1; % Find p (BPSK) p_a = Q(sqrt(2 * r_a * EbNo)); p_b = Q(sqrt(2 * r_b * EbNo)); % Perform summations for i = 0:t_a p_term_a(i+1,:) = nchoosek(n_a,i) * p_a .^ i .* (1 - p_a) .^ (n_a - i); end for i = 0:t_b p_term_b(i+1,:) = nchoosek(n_b,i) * p_b .^ i .* (1 - p_b) .^ (n_b - i); end % Calculate codeword error probabilities Pc_a = 1 - sum(p_term_a); Pc_b = 1 - sum(p_term_b); % Calculate bit error probabilities Pb_a = dmin_a * Pc_a / n_a; Pb_b = dmin_b * Pc_b / n_b; Pb_c = Q(sqrt(2 * EbNo));

% Create a vector of arbitrarily low Pb Pb_low = 10^-5 * ones(1, length(Pb_c)); % Find the value of EbNodB when the curves cross 10^-5 [Pb_a_val Pb_a_index] = min(abs(Pb_a - Pb_low)); [Pb_b_val Pb_b_index] = min(abs(Pb_b - Pb_low)); [Pb_c_val Pb_c_index] = min(abs(Pb_c - Pb_low)); SNR_a = EbNodB(Pb_a_index); SNR_b = EbNodB(Pb_b_index); SNR_c = EbNodB(Pb_c_index); % Find the coding gains of BCH(255,207) and BCH(255,99) coding_gain_a = SNR_c - SNR_a coding_gain_b = SNR_c - SNR_b % Find the value of the capacity curve for a coderate r=k/n minSNR_a = 10 * log10((2 ^ (2 * k_a / n_a) - 1) / (2 * k_a / n_a)); minSNR_b = 10 * log10((2 ^ (2 * k_b / n_b) - 1) / (2 * k_b / n_b)); % Find the distance between the BCH codes and the unconstrained input dist_from_capacity_a = SNR_a - minSNR_a dist_from_capacity_b = SNR_b - minSNR_b % Plot results semilogy(EbNodB,Pc_a,EbNodB,Pc_b,EbNodB,Pb_c,EbNodB,Pb_low,'k:') axis([min(EbNodB) max(EbNodB) 1e-6 1]) title('Bit error probabilities of BCH codes with BPSK modulation') xlabel('E_b/N_o in dB') ylabel('P_b') legend('(255,207) BCH code', '(255,99) BCH code', 'BPSK w/o ECC')

3. In this problem, you are to compare the performance of 2 different Reed Solomon codes. Code 1 is a (7,5) Reed Solomon code and code 2 is a (63,45) Reed Solomon code. a) Compute the code word error probability of the 2 codes if 8-PSK modulation is used along with hard-decision decoding. For the (7,5) code, each 8-ary symbol at the output of the encoder is simply mapped to a single 8-PSK signal. However, for the (63,45) code, each 64-ary symbol at the output of the encoder is mapped to a pair of 8-PSK signals (and thus the symbol is received incorrectly if either signal is in error). Your answer should be an expression in terms of Eb/No. b) Repeat part (a) for noncoherently detected 8-FSK modulation. c) Plot all four expressions derived in (a) and (b) using a semilogy axis. Eb/No should be in dB and the code word error probability should go down to 10-8.

Here

s
N0

Eb E Rm = b R(3) N0 N0 n k

Consider (7,5) RS code: n=7 ; k=5 ; r=k/n=5/7 ; dmin=n-k+1=3 ; t = = 1 ; m=log2(n+1)=3 ; 2

s
N0

E Eb 15 E 5 E Rm = b R(3) = 3 b = b N0 N0 7 N0 7 N0
n n i n i and Pc p (1 p ) i i =t +1

For 8-PSK:

2 s p = 2Q N sin M 0
For 8-FSK:
M 1

n k s M 1 (1) k +1 n and Pc p i (1 p ) ni p = exp k k +1 k =1 i =t +1 i (k + 1) N 0

Consider (63,45) RS code: n=63 ; k=45 ; r=k/n=45/63 ; dmin=n-k+1=19 ; t = = 9 ; m=log2(n+1)=6 ; 2

n k

s
N0

Eb E 45 E 15 E Rm = b R(3) = 3 b = b N0 N0 63 N 0 7 N 0

For 8-PSK:
n 2 s n sin and p = 1 (1 ps ) 2 and Pc p i (1 p ) ni ps = 2Q N M i =t +1 i 0

For 8-FSK:
M 1 M 1 k s (1) k +1 2 ps = k k + 1 exp (k + 1) N and p = 1 (1 ps ) and k =1 0 n n Pc p i (1 p ) ni i =t +1 i

MATLAB CODE: % (7,5) RS code M=8; Eb_N0_db=0:0.5:20; Eb_N0=10.^(Eb_N0_db./10); n=7; k=5; r=k/n; m=log2(n+1); dmin=n-k+1; t=floor((n-k)/2); % 8-PSK p=2*Q(sqrt(2*Eb_N0*log2(M))*sin(pi/M)); Pc=0; for i=t+1:n Pc=Pc+nchoosek(n,i)*(p.^i).*((1.-p).^(n-i)); end semilogy(Eb_N0_db,Pc,'b*-') hold on % 8-FSK Ps=0; for j=1:M-1 Ps=Ps+nchoosek(M-1,j)*(-1)^(j+1)/(j+1)*exp(-j/(j+1)*Eb_N0*r*log2(M)); end p=Ps; Pc=0; for i=t+1:n Pc=Pc+nchoosek(n,i)*(p.^i).*((1.-p).^(n-i)); end semilogy(Eb_N0_db,Pc,'r^-') hold on % (63,45) RS code M=64; Eb_N0_db=0:0.5:20; Eb_N0=10.^(Eb_N0_db./10); n=63; k=45; r=k/n; m=log2(n+1); dmin=n-k+1; t=floor((n-k)/2); % 8-PSK ps=2*Q(sqrt(2*Eb_N0*r*log2(M))*sin(pi/M)); p=1-(1-ps).^2; Pc=0; for i=t+1:n Pc=Pc+nchoosek(n,i)*(p.^i).*((1.-p).^(n-i)); end semilogy(Eb_N0_db,Pc,'kp-') hold on % 8-FSK Ps=0; for j=1:M-1 Ps=Ps+nchoosek(M-1,j)*(-1)^(j+1)/(j+1)*exp(-j/(j+1)*Eb_N0*log2(M)); end p=1-(1-Ps).^2; Pc=0; for i=t+1:n Pc=Pc+nchoosek(n,i)*(p.^i).*((1.-p).^(n-i)); end semilogy(Eb_N0_db,Pc,'mo-') xlabel('Eb/N0 in dB') ylabel('Codeword error probability') axis([0 16 10^-8 1]) legend(' (7,5) RS code for 8-PSK',' (7,5) RS code for 8-FSK',' (63,45) RS code for 8-PSK',' (63,45) RS code for 8-FSK')

PLOT:

10

10

-1

(7,5) RS code for 8-PSK (7,5) RS code for 8-FSK (63,45) RS code for 8-PSK (63,45) RS code for 8-FSK

10

-2

Codeword error probability

10

-3

10

-4

10

-5

10

-6

10

-7

10

-8

8 Eb/N0 in dB

10

12

14

16