S834 of 56
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S8 · Lesson 34 · Linear block codes

Adding structured redundancy, generator and parity-check matrices, Hamming distance and what it detects and corrects, Hamming and Golay codes, syndrome decoding and block error probability

The coding theorem says reliable communication is possible near capacity, but only through redundancy cleverly arranged. Block codes were the first practical answer: take k data bits, append n − k check bits computed from them, and send the n-bit codeword. If the valid codewords all differ from each other in at least dmin places, a few flipped bits leave the received word closer to the right codeword than to any other. Richard Hamming's 1950 code, built because a relay computer kept stopping on parity errors over the weekend, corrects any single error in seven bits with three check bits.

  • Block error probability against Eb/N0 for 4 data bits sent uncoded, as a Hamming (7,4) codeword, and 12 data bits as a Golay (23,12) codeword (hard decisions, BPSK; coded bits get energy (k/n)Eb).
  • The Hamming code corrects one error per block but spends 43% of its energy on check bits: it gains only about 0.7 dB at a block error rate of 10⁻⁵.
  • The Golay code corrects three errors in 23 and gains about 2.8 dB there; stronger codes (lessons 35 and 36) gain far more.

Predict

A code's codewords all differ in at least 5 positions. How many bit errors per block can it always correct?

Name it

Linear block codes

An (n, k) code maps k data bits to an n-bit codeword; its rate is R = k/n. A linear code's codewords are 𝐜=𝐝G for a k × n generator matrix G (often systematic, G=[Ik|P]), and every codeword satisfies 𝐜HT=0 for the (n − k) × n parity-check matrix H=[PT|In−k].

Distance

The Hamming distance between two words is the number of places they differ; for a linear code, dmin equals the smallest weight of a nonzero codeword. A code can

  • detect up to dmin−1 errors;
  • correct up to t=⌊(dmin−1)/2⌋ errors.

Hamming and Golay codes

  • Hamming codes: n=2m−1, k=n−m, dmin = 3: the columns of H are all nonzero m-bit patterns, so the syndrome 𝐬=𝐫HT of a single error is the column at the error's position, which it names directly.
  • Golay (23,12): dmin = 7, t = 3.
  • Both are perfect: the 2n−k syndromes exactly cover all patterns of up to t errors, ∑i=0t(ni)=2n−k (the Hamming bound met with equality).

Performance

With hard decisions and coded-bit error probability p=Q(2REb/N0), a t-error-correcting code fails when more than t errors occur:

Pblock=1−∑i=0t(ni)pi(1−p)n−i

Spreading the bit energy over more transmitted bits raises p, so a code must correct enough errors to come out ahead.

Worked example

With raw bit error probability p = 0.01, compare 4 uncoded bits with a Hamming (7,4) codeword and a Golay (23,12) codeword.

Show the solution
  1. Uncoded 4-bit block. 1−0.994=0.039
  2. Hamming (7,4). P=1−0.997−7(0.01)(0.996)=0.0020
  3. Golay (23,12). P=1−∑i=03(23i)pi(1−p)23−i=7.6×10−5
  4. A caveat. At equal Eb/N0 the coded bits have higher p because each carries less energy; the sim accounts for that.

Answer block error probabilities of 0.039 uncoded, 0.0020 with the Hamming code and 7.6 × 10⁻⁵ with the Golay code.

Worked example

Check that the Golay (23,12) code is perfect.

Show the solution
  1. Count the correctable patterns. N=1+23+(232)+(233)=1+23+253+1771=2048
  2. Count the syndromes. 223−12=211=2048
  3. Perfect. Every one of the 2048 syndromes corresponds to exactly one correctable error pattern, with none left over.

Answer the 2048 patterns of up to three errors exactly fill the 2048 syndromes, so the code is perfect.

Worked example

A Hamming (15, 11) code sees raw bit errors with probability 0.001. What is its block error probability, against 11 uncoded bits?

Show the solution
  1. Coded block. It fails only with two or more errors: P=1−0.99915−15(0.001)(0.999)14=1.04×10−4
  2. Eleven uncoded bits. They arrive with at least one error with probability 1−0.99911=0.011
  3. Compare. That's a hundredfold improvement for a 27% rate penalty.
  4. At p = 0.01. The gain would be far smaller, as double errors become common.

Answer 1.04 × 10⁻⁴ for the Hamming block, against 0.011 for 11 uncoded bits.

Check

A code has dmin = 5. How many errors per block can it always correct?

Check

A Hamming code has m = 4 check bits. How many data bits does each codeword carry?

Check

A single-error-correcting code of length 15 sees raw bit errors with probability 0.001. What's its block error probability?

Check

A Hamming code puts 11 data bits into each 15-bit codeword. What's its rate?

Check

A rate-0.571 code is sent with BPSK at Eb/N0 = 6 dB and hard decisions. What's the raw coded-bit error probability?

Check

How many error patterns of weight 0 or 1 are there in a 15-bit word, the number a single-error-correcting code's syndromes must distinguish?

Check

A Hamming code with m = 4 check bits sees raw bit errors with probability 0.001.

(a)

What is its rate?

(b)

What is its block error probability?

Check

A Hamming code has m check bits; separately, a single-error-correcting code has length n.

Step 1

What is the Hamming code's length?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why can a code with minimum distance d correct ⌊(d − 1)/2⌋ errors but no more?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.