Hamming(7,4)

While multiple overlaps can be created, the general method is presented in Hamming codes.

For example, d1 is covered by p1 and p2 but not p3 This table will have a striking resemblance to the parity-check matrix (H) in the next section.

Furthermore, if the parity columns in the above table were removed then resemblance to rows 1, 2, and 4 of the code generator matrix (G) below will also be evident.

For the purposes of Hamming codes, two Hamming matrices can be defined: the code generator matrix G and the parity-check matrix H: As mentioned above, rows 1, 2, and 4 of G should look familiar as they map the data bits to their parity bits: The remaining rows (3, 5, 6, 7) map the data to their position in encoded form and there is only 1 in that row so it is an identical copy.

In fact, these four rows are linearly independent and form the identity matrix (by design, not coincidence).

For the remainder of this section, the following 4 bits (shown as a column vector) will be used as a running example: Suppose we want to transmit this data (1011) over a noisy communications channel.

Programmers concerned about multiplication should observe that each row of the result is the least significant bit of the Population Count of set bits resulting from the row and column being Bitwise ANDed together rather than multiplied.

Performing this multiplication (again, entries modulo 2): Since the syndrome z is the null vector, the receiver can conclude that no error has occurred.

The bit error can be detected by computing the parity of the red, green, and blue circles.

In the above example, the red and green circles have bad parity so the bit corresponding to the intersection of red and green but not blue indicates the errored bit.

Now, which corresponds to the fifth column of H. Furthermore, the general algorithm used (see Hamming code#General algorithm) was intentional in its construction so that the syndrome of 101 corresponds to the binary value of 5, which indicates the fifth bit was corrupted.

Once the received vector has been determined to be error-free or corrected if an error occurred (assuming only zero or one bit errors are possible) then the received data needs to be decoded back into the original four bits.

Using the running example from above It is not difficult to show that only single bit errors can be corrected using this scheme.

This yields only one circle (green) with an invalid parity but the errors are not recoverable.

Similarly, Hamming codes cannot detect or recover from an arbitrary three-bit error; Consider the diagram: if the bit in the green circle (colored red) were 1, the parity checking would return the null vector, indicating that there is no error in the codeword.

For instance, the extended (8,4)-Hamming code, which arises from the addition of a parity bit, is also related to the E8 lattice.

Graphical depiction of the 4 data bits d 1 to d 4 and 3 parity bits p 1 to p 3 and which parity bits apply to which data bits
Bit position of the data and parity bits
Mapping in the example x . The parity of the red, green, and blue circles are even.
A bit error on bit 5 causes bad parity in the red and green circles.
A bit error on bit 4 & 5 are introduced (shown in blue text) with a bad parity only in the green circle (shown in red text)