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 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 ).
- 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?
Two. With = 5, a received word with 2 errors is still at distance 2 from the true codeword and at least 3 from any other, so nearest-codeword decoding picks the right one. With 3 errors it might be closer to a wrong codeword. In general a code corrects errors, or detects .
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 for a k × n generator matrix G (often systematic, ), and every codeword satisfies for the (n − k) × n parity-check matrix .
Distance
The Hamming distance between two words is the number of places they differ; for a linear code, equals the smallest weight of a nonzero codeword. A code can
- detect up to errors;
- correct up to errors.
Hamming and Golay codes
- Hamming codes: , , = 3: the columns of H are all nonzero m-bit patterns, so the syndrome of a single error is the column at the error's position, which it names directly.
- Golay (23,12): = 7, t = 3.
- Both are perfect: the syndromes exactly cover all patterns of up to t errors, (the Hamming bound met with equality).
Performance
With hard decisions and coded-bit error probability , a t-error-correcting code fails when more than t errors occur:
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
- Uncoded 4-bit block.
- Hamming (7,4).
- Golay (23,12).
- 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
- Count the correctable patterns.
- Count the syndromes.
- 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
- Coded block. It fails only with two or more errors:
- Eleven uncoded bits. They arrive with at least one error with probability
- Compare. That's a hundredfold improvement for a 27% rate penalty.
- 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 = 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°.
Step 2
How many data bits does it carry?
Step 3
How many error patterns must a single-error-correcting code of length n distinguish?
Explain why
Why can a code with minimum distance d correct ⌊(d − 1)/2⌋ errors but no more?
Picture every codeword surrounded by a sphere containing all the words within distance t of it. If 2t is less than the minimum distance, these spheres don't overlap, so any received word with t or fewer errors lies inside exactly one sphere, its own codeword's, and the decoder can identify it unambiguously by choosing the nearest codeword. With t + 1 errors and t = ⌊(d − 1)/2⌋, a received word can land halfway or more toward another codeword, where it's at least as close to the wrong one, and the decoder fails. Detection is easier: any error pattern of fewer than d bits can't turn one codeword into another, so it's always noticed even when it can't be fixed.
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.