Three overlapping parity checks find which bit flipped and repair it: how to read them as a number in base 2, what happens when two bits flip, and what it costs.
Step 1 of 6 · Three overlapping checks
Step 1 of 6
Three overlapping checks
In 1950 Richard Hamming published a code that does not just catch a flip, but finds it. The Hamming (7,4) code adds three parity bits to every four data bits, making blocks of seven. Number the positions in a block from to . The parity bits sit in positions , and , and each belongs to a different check:
- Check A covers positions , , and .
- Check B covers positions , , and .
- Check C covers positions , , and .
Each parity bit is set so that its check holds an even number of 1s. On the board above the line the checks are drawn as three overlapping circles, and each position has a region of its own.
Here the line is perfectly quiet, and Faulty bit picks one position that flips in every block, as if one wire in the cable were broken. This time it is position .
Step 2 of 6
Reading the checks
When one bit flips, every check that covers it fails, and the others pass. The checks were chosen so that this pattern is the position itself, written in base 2: check A is the ones digit, B the twos digit, and C the fours digit. So read them in the order C B A and write for each check that failed. That number is called the block’s syndrome, and means every check passed.
Now Faulty bit is hidden, and Look inside is closed.
Step 3 of 6
Parity bits flip too
The noise does not know which bits are data and which are parity: a parity bit can flip on the way too. Positions , and , the powers of , are exactly the positions inside one circle only. Flipping one of them fails only its own check, and the syndrome points to it like any other position.
Step 4 of 6
Two flips
Look inside is open at Repaired: the receiver flips the bit the syndrome points to, and the display shows the repaired text. The line is noisy again, 5% per bit. The code assumes that at most one bit flips in each block. When two flip, what the receiver sees is the pattern of a single flip, somewhere else.
Step 5 of 6
How often the code fails
With the code, a block arrives wrong only if two or more of its seven bits flipped. The counter compares the last blocks with and without the code.
Step 6 of 6
The price
Three bits out of every seven on the line carry no part of the message. That is the price of repair: the line carries data at only of its rate. Modern codes, in phones, on CDs and on spacecraft, repair far more errors at a lower price, but their idea is the same: overlapping parity checks whose answers together point to the error.
Loading the interactive version…
Loading the interactive version…
Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.
Practice · Predict, then look
The line is perfectly quiet, but Faulty bit is 6: in every block the bit in position 6 flips. Which of the checks A, B and C will fail? Choose, and then Look inside moves to Parity checks.
Practice · Predict, then look
The line is perfectly quiet, but Faulty bit is 6: in every block the bit in position 6 flips. Which of the checks A, B and C will fail? Choose, and then Look inside moves to Parity checks.
Practice · Calculate
A new fault on the line, and this time you are not shown where. In every block checks A and B fail, and check C passes. In which position does the bit flip?
Practice · Calculate
A new fault on the line, and this time you are not shown where. In every block checks A and B fail, and check C passes. In which position does the bit flip?
Practice · Reach the target
Change Faulty bit until only check C fails, while A and B pass. Press Check.
Practice · Reach the target
Change Faulty bit until only check C fails, while A and B pass. Press Check.
Practice · Choose
In one block two bits flip, in positions 3 and 5. What does the receiver do?
Practice · Choose
In one block two bits flip, in positions 3 and 5. What does the receiver do?
Practice · Calculate
Chance a bit flips is fixed at 5%, and the code repairs. A coded block arrives wrong only if two or more of its seven bits flipped. What is the chance of that? Answer in per cent.
Practice · Calculate
Chance a bit flips is fixed at 5%, and the code repairs. A coded block arrives wrong only if two or more of its seven bits flipped. What is the chance of that? Answer in per cent.
Practice · Calculate
The message HELLO is five characters, eight bits each, sent in blocks of four bits. How many bits does one copy of it take on the line with Hamming’s code?
Practice · Calculate
The message HELLO is five characters, eight bits each, sent in blocks of four bits. How many bits does one copy of it take on the line with Hamming’s code?
Lesson complete. Every practice question here is done.