Lab 9 - The [7,4,3]-Hamming Code (May 2)

My code for this lab

Task 1: (go through the encoding/decoding process with no noise/no corrections)
Take the test string s, and convert it into a string b of 4-bit blocks. Encode b with the generator matrix G with the product x = bG. Now one decodes with y = xR. Recovert to a string and check you get s back.

Task 2: Write a function pos(u) that takes in a 3-bit vector and returns the corresponding integer between 0 and 7 so u is the binary representation of this number. Here low order bits are to the left, i.e., u = [1, 0, 0] corresponds to 1 and u = [0, 0, 1] corresponds to 4.)

Task 3: Write a function correct(y) that takes a list y of 7-bit words and applies nearest neighbor decoding as follows. For each word w in y, compute the "syndrome" u = wHT, where HT is the transpose of H. Flip the bit of w in position pos(u)-1 (since position are indexed starting at 0, not at 1---if u = [0, 0, 0], then do nothing). Here, feel free to modify the list y itself, so this function does not need to return anything. Test this out by taking a codeword w, say w = G[0][:7] (this will copy the first row of G---if you just set w = G[0], modifying w will modify G), modifying a single bit, and calling correct([w]).

Task 4: Take the test string s, and encode it as a bit matrix x. Apply noise to x with probability p=0.05 to get a garbled bit matrix y. Try to decode both without and with error correction, i.e., look at the string for yR first without correcting y, then with correcting y. How much of the string is readable in each case? Try experimenting with different values of p. What's approximately the smallest value of p for which the message becomes unreadable?



Labs Page
Course Home