Previous, Math 511 Home, Contents, Next

Error Correcting Codes

Parity checks give us a way to detect if an error has occurred in recording a byte of data. But often just knowing that an error has occurred isn't sufficient; you want to know what the error was and how to fix it. Richard Hamming at Bell Labs was having a problem with parity errors in the 50's while working at Bell Labs. Because the only computer (back in the 50's computers weren't household items) was busy with high priority projects during the week, Hamming could only submit his jobs to be run over the weekend. For several weeks, each Monday when he came in he got the message that the program had terminated with a parity error and to please try again. Of course, trying again meant waiting till the next weekend. Hamming thought there had to be a way to set things up to use parity to correct a single error, rather than just detecting it. He worked out a method to do just that, now called the Hamming code.

The (7,4) Hamming code uses four data bits and three parity bits (for a total of seven bits). Suppose the data bits are b1b2b3b4. We set the parity bit p123 so b1b2b3p123 has even parity. Then we set the parity bit p124 so b1b2b4p124 has even parity. Finally we set the parity bit p134 so b1b3b4p134 has even parity. We then encode our results as b1b2b3b4p123p124p134. We can write this in terms of matrices as

where the computation is done mod 2.

Let's look at an example. Suppose our four data bits are 0110. Then we compute the parity bits p123 = 0, p124 = 1, and p134 = 1, and we get our seven-bit result 0110011. To test this sequence for errors, we check the parity of the sets b1b2b3p123, b1b2b4p124, and b1b3b4p134, which in this case are 0110, 0101, and 0101 respectively. Since all three have even parity, we detect no errors. Now suppose an error changes our seven-bit sequence to 0111011. This time when we look at the sets b1b2b3p123, b1b2b4p124, and b1b3b4p134, we get 0110, 0111, and 0111 respectively. Since two of these have odd parity, we detect an error. Looking at which sequences have errors, we see that we have detected no error in b1b2b3p123, but we have detected an error in b1b2b4p124, and b1b3b4p134. Assuming that there is only a single error (which we hope is more likely than there being two errors), we can conclude that the error is in bit b4, since it is the only bit that is in both sets b1b2b4p124 and b1b3b4p134 but not in b1b2b3p123. So we switch bit b4 in the errant sequence 0111011 from a 1 to a 0 to get back to the correct seven-bit sequence 0110011. Extracting the four data bits, we finally get 0110, which is what we started this paragraph with.

Since every bit, both data and parity, is in at least one of the sets b1b2b3p123, b1b2b4p124, and b1b3b4p134, any change in a single bit will foul up at least one of the three parity checks. On the other hand, since no two bits are in exactly the same parity checks, we can always determine which single bit was changed by examining which parity checks fail.


Please report any problems with this page to bennett@math.ksu.edu
©1998 Andrew G. Bennett