Part III · Chapter 9

Repetition and Parity

The two oldest tricks for beating noise: say everything several times and let the copies vote, or add a single check bit that notices when something went wrong. Both work. Both have a price. Measuring that price is how we learn to do better.

Radio operators spell words with "Alpha, Bravo, Charlie" instead of "A, B, C". The long words are redundancy on purpose: "B", "D", "E" and "P" blur together through static, while "Bravo", "Delta", "Echo" and "Papa" are hard to confuse. When a message is really important, operators also read it back. Both habits spend extra time on the air to buy reliability.

Chapter 8 left us with a plan: compress away the redundancy you did not choose, then add back redundancy you did choose, designed to fight noise. This chapter tries the two simplest designs on the binary symmetric channel and measures what each one buys and what it costs.

Say it three times

The bluntest design is the repetition code: send every bit n times (n odd), and let the receiver take a majority vote. With three copies, one flip among the three is outvoted; it takes two flips in the same triple to fool the receiver. If one bit in a hundred flips (p = 1%), the chance of two or three flips in a triple is about 3 in 10,000. Errors fall by a factor of about 30.

The price is the rate: the fraction of transmitted bits that carry new data. Sending every bit three times has rate 1/3; the same message takes three times as long. Explore the trade below.

Interactive 9.1Majority Vote
Change the number of copies and the noise
copies as received flipped copies and wrong decisions bits the vote got right
3
10.0%
 
Each extra pair of copies cuts the error probability further, but the points in the lower chart march steadily to the left: toward rate zero. To make errors vanish entirely with repetition you would have to send each bit infinitely many times. The error curve and the rate are locked together.
The repetition bargain

Repetition can make errors as rare as you like, but only by sending the rate toward zero.

One bit that notices

A much cheaper idea: add one extra bit to each block so that the total number of 1s is always even. This parity bit costs one bit per block: with 7 data bits, the rate is 7/8, far better than 1/3. If any single bit flips on the way, the count of 1s becomes odd, and the receiver knows something went wrong.

Interactive 9.2The Parity Bit
Set the data, then flip received bits as the noise
data bits parity bit bits flipped by noise
Sent data (click to change):
Noise (click to flip a received bit):
 
Flip one bit: detected. Flip a second: the count is even again and the receiver says "fine", though two bits are wrong. A parity bit catches any odd number of flips and misses every even number. And even when it catches an error, it cannot say which bit is wrong, so it cannot fix it.

Detection alone is still valuable. When the receiver can talk back, it can simply ask for the block again. Much of the internet works this way: data travels in packets with check values, and damaged packets are re-sent. But a deep-space probe, a disc, or a memory chip has no one to ask. For those, the receiver must locate and fix errors on its own.

Locating an error with a grid

Here is a neat way to turn detection into location. Lay 16 data bits out in a 4 × 4 grid. Add a parity bit to every row and every column (and one in the corner to check the checks), so that every row and every column of the full 5 × 5 grid has an even number of 1s. Now a single flipped bit makes exactly one row and one column fail. They cross at the culprit.

Interactive 9.3The Parity Grid
Click any cell to flip it, then fix it
data bits parity bits failing rows and columns, and the flipped bits the located culprit
 
One flip anywhere, even in a parity bit, is located and fixed. Two flips are always noticed but cannot be located: in different rows and columns, two rows and two columns fail and four cells are suspects; in the same row, only two columns fail. Rate: 16 data bits out of 25 sent, or 0.64.

The grid fixes any single error with 9 check bits for 16 data bits, far cheaper than tripling everything. But it is not the cleverest possible design. Each check bit answers a yes-or-no question ("is there an error in this row?"). With 16 data bits and 5 check bits there would be 21 places an error could hide, plus "no error at all": 22 situations to tell apart. Five well-chosen yes-or-no answers give 25 = 32 possible replies, enough to name every one of them. So 5 check bits could in principle do the job of the grid's 9, for fixing single errors. (The grid also notices every double error, which takes one more check bit, as Chapter 10 shows.) Chapter 1's twenty-questions logic, applied to errors! Richard Hamming found codes that achieve exactly that, and they are the subject of the next chapter.

Detect, locate, correct

A parity check detects; crossing several parity checks locates; and in binary, locating is correcting, because a wrong bit has only one other value it could be.

Intuition Check

A received block passes its parity check. What can you conclude?

Intuition Check

At p = 10%, the 25-copy repetition code makes decoded errors astronomically rare. Why is it still a poor answer to noise?

Connections

What you now see

  • The rate of a code is the fraction of sent bits that carry new data.
  • Repetition with majority vote cuts errors steeply, but driving errors toward zero drives the rate toward zero too.
  • A single parity bit detects any odd number of flips at a tiny cost, misses even numbers, and cannot locate.
  • Crossing row and column parities locates, and therefore fixes, any single error; two errors are detected but not located.
  • Naming one position among N needs only about log₂ N yes-or-no checks: the grid uses more check bits than necessary.