Parity-check matrix for the (7,4) code — Hamming code

edge casethe linear-algebra view

Answer

H is 3×7

Why this example is worth doing

The same code expressed as matrices: the syndrome is H times the received vector over GF(2), and the columns of H are simply the numbers one to seven written in binary. Seeing that makes the syndrome-equals-position property a triviality rather than a coincidence. The page includes this view because it is the one that generalises to every other linear code, and it is where a coding-theory course picks up.

Try your own input in the Hamming code. Encode, inject an error, and watch the syndrome point straight at the flipped bit.

How the answer is reached

Hamming (7,4) matrices over GF(2)

Position-ordered parity-check matrix H: column c is position (c + 1) written in binary, least significant bit in row 0.

H (position-ordered) — Hamming (7,4) matrices over GF(2)
1234567
1010101
0110011
0001111
G (position-ordered): row i is the codeword of the unit data word e_i — Hamming (7,4) matrices over GF(2)
1234567
1110000
1001100
0101010
1101001

Systematic form puts the payload first: G = [I_k | P] and H = [Pᵀ | I_{n−k}], so G·Hᵀ = P + P = 0.

G = [I_k | P] — Hamming (7,4) matrices over GF(2)
1234567
1000110
0100101
0010011
0001111
H = [Pᵀ | I_{n−k}] — Hamming (7,4) matrices over GF(2)
1234567
1101100
1011010
0111001
Warning:

Encoding is c = m·G and the syndrome is s = H·rᵀ, both over GF(2).

Source: R. W. Hamming, Bell System Technical Journal 29(2):147–160 (1950)

Compare with

Open the Hamming code

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Hamming positions are numbered from 1 at the left, and parity bits sit at the powers of two — positions 1, 2, 4, 8.

Sources

  • Hamming, “Error Detecting and Error Correcting Codes” (1950)