Note: A Hamming code satisfies the relation 2m ≥ n+1, where n is the total number of bits in the block, k is the number of information bits in the block, and m is the number of check bits in the block, where m = n- k .
We write a matrix
Writing out the multiplication, we end up with
On decoding, assume one error has occurred in the received codeword r. (this Hamming code cannot detect when more than one error has occurred).
If no error has occurred, we have constructed the codeword to be sent so Hc=0 so we can check this. Say an error has occurred in the ith place, so
Then
Source: from Federal Standard 1037C
See also: Hamming distanceHamming codes in action
Let us examine the Hamming (7, 4) code.
(note each column is a binary digit) and we create a codeword vector:
where a, b, and c are check digits, created by making the multiplication Hc=0.
and we send the codeword c with these values.
where ei is a vector with a 1 in the ith place and zeroes otherwise.
Now Hc=0, so
picking out the ith column of H, and thus since this column is a binary digit (say k), we can correct the error in the kth place of the received codeword.