% p1 a. Input Codeword 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 0 1 0 0 0 0 1 1 1 1 1 1 1 b. Only the codewords are legal, thus 4. (4/32 = 1/8) c. 4 (codewords) * 5 (bits/codewords) = 20 d. 32 - 20 - 4 = 8 e. Let's see if I can find a another codebook with reduced number of 1's. Input Codeword 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 1 I used Hamming. I think it can't be reduced further than 10. % p2 G = [1 0 0 0 1 1 1; 0 1 0 0 0 1 1; 0 0 1 0 1 0 1; 0 0 0 1 1 1 0] H = [1 0 1 1 1 0 0; 1 1 0 1 0 1 0; 1 1 1 0 0 0 1] % a D = [0:1:15]; PATTERN = de2bi(D,4,'left-msb') % b CODEBOOK = mod(PATTERN * G,2) % c % matrix H can correct 1 errors or detect 2. % d-e % I am simply going to test all of the 16 possibilities: % (d) without errors B = CODEBOOK C = mod(B*H',2) % should return all 0's % (e1) with errors in the message B = CODEBOOK % alter all third bits B(1:16,3) = ~B(1:16,3) C = mod(B*H',2) B = CODEBOOK % alter first bit of first, % second of second, etc. for i = 1:1:7, B(i,i) = ~B(i,i) end C = mod(B*H',2) % from this: % 1st bit alteration -> 1 1 1 % 2nd bit alteration -> 0 1 1 % 3rd -> 1 0 1 % 4th -> 1 1 0 % 5th -> 1 0 0 % 6th -> 0 1 0 % 7th -> 0 0 1 % f % alter all 3rd and 2nd bits B = CODEBOOK B(1:16,2:3) = ~B(1:16,2:3) C = mod(B*H',2) % C returns rows of 1 1 0, similar to an error in the 4th bit, let's check: B = CODEBOOK B(1:16,4) = ~B(1:16,4) C = mod(B*H',2) % OK % p3 a. Ben's efficiency is higher, but not incrediby so. Coderates: Ben's 8 / 16 = 1/8 = 0.125 Mine's 8 / 18 = 1/9 = 0.111 b. All single errors can be corrected with Ben's design. * If the error occurs in a data bit, then one row and and one column parity bits won't agree with the data. The erroneous data bit can then be inferred and corrected from these row and column parity bits. * If the error occurs in a parity bit, then only IT won't agree with the data. Thus it must be wrong and corrected. c. Doube errors where each error is on a different part can be corrected, because in these cases, we can think of them as "separate" simple errors, and apply the strategies described in b. d. No. Counter example: The situation were PR0 and PC0 are erroneous can be confused with the one were only D0 is.