How Do Hamming Codes Correct Single-Bit Errors?

TL;DR
Hamming codes correct a single flipped bit by applying parity checks to carefully selected subsets of a data block, allowing the receiver to determine the error's exact position. This adds far less redundancy than storing three copies of every bit. A related scheme can use 9 redundant bits in a 256-bit block, leaving 247 positions for meaningful data.
Transcript
Have you ever wondered how it's possible to scratch a CD or a DVD and still have it play back whatever it's storing? The scratch really does affect the 1s and 0s on the disk, so it reads off different data from what was stored, but unless it's really scratched up, the bits it reads off are decoded into precisely the same file that was encoded onto ... Read More
Key Insights
- Error correction codes add structured redundancy so stored or transmitted data can survive bit flips. The receiver uses the redundant structure to distinguish valid messages from altered ones and, within the scheme's supported error limit, recover the message that the sender originally encoded.
- Triple repetition corrects one flipped copy by selecting the value held by two of the three copies. However, it spends two thirds of the available space on redundancy and provides no strong guarantee when more than one copy of a bit is flipped.
- A 256-bit block can reserve 9 bits for redundancy while leaving 247 bits for meaningful data. Under the described method, any single flipped bit can be located and corrected using only that block, while two flipped bits can at least be detected.
- Valid-message spacing is the basic principle behind error correction. Only a subset of all possible bit sequences is accepted as valid, so an altered sequence can be corrected toward a nearby valid sequence, in a process analogous to recognizing and fixing a misspelled word.
- Richard Hamming developed the first error correction code at Bell Labs during the 1940s. His programs ran on a large, expensive punch card computer with limited access, and recurring failures caused by misread bits motivated him to devise a method for correcting errors.
- A parity check uses one adjustable bit to make the total number of 1s in a selected group even. Any odd number of bit flips makes the resulting parity odd, revealing an error, while an even number of flips leaves the parity even.
- Parity alone detects change but does not identify its location. Hamming's central insight was to apply parity checks to carefully chosen subsets, turning each result into a refined clue that progressively narrows the possible position of a single error.
- Power-of-two positions are reserved for parity bits in the 16-position example. One check covers odd-numbered positions and uses position 1, while another covers a different half of the arranged positions and uses position 2, providing complementary location information.
Install to Summarize YouTube Videos and Get Transcripts
Explore YouTube Video Summarizer or Get YouTube Transcript Extractor
Questions & Answers
Q: How do Hamming codes correct a single-bit error?
Hamming codes apply multiple parity checks to carefully selected subsets of a bit block. Each check reports whether its subset has the expected even parity. If one bit flips, the pattern of failed and successful checks acts like a series of yes-or-no clues, identifying the bit's position. The receiver can then flip that bit back to correct the block.
Q: What is a parity check in error correction?
A parity check reserves one bit that the sender adjusts so a selected group contains an even number of 1s. If any single bit in that group later flips, the number of 1s becomes odd. The receiver can therefore determine that an error occurred, although one parity check by itself does not reveal which bit changed.
Q: Why is storing three copies of each bit inefficient?
Storing three copies allows a receiver to compare them and choose the value shared by at least two copies when one differs. The cost is that two thirds of the storage is devoted to redundancy rather than meaningful data. Even with that large overhead, the method provides no strong guarantee if more than one copy is flipped.
Q: Why do Hamming codes check selected subsets of bits?
Checking selected subsets provides more information than applying one parity test to the full message. A failed check indicates that the error lies inside that subset, while a successful check places it outside the subset, assuming at most one error. Several well-chosen checks combine these partial clues to pinpoint the exact position of a flipped bit.
Q: What can one parity bit detect?
One parity bit can reveal any odd number of flips within the group it checks because those changes switch the total count of 1s between even and odd. It cannot reliably detect an even number of flips, since two or any other even number of changes preserves the original parity. It also cannot identify the changed positions.
Q: How much redundancy can the described error correction method use?
The described method can organize data into 256-bit blocks containing 9 bits of redundancy and 247 bits of meaningful information. If any one bit in such a block flips, the receiver can identify its precise position and correct it using only that block. If two bits flip, the scheme can detect the two errors but cannot correct them.
Q: Why are parity bits placed at power-of-two positions?
In the 16-position example, four special bits are placed at positions that are powers of 2 because this arrangement leads to an elegant set of parity checks and hints at how the method scales to larger blocks. Position 1 controls a check over odd-numbered positions, while position 2 controls another selected group of eight positions.
Q: What inspired Richard Hamming to create error correction codes?
During the 1940s, Richard Hamming worked at Bell Labs and used a large, expensive punch card computer that he could access only on a limited basis. His submitted programs repeatedly failed because bits were occasionally misread. Frustration with those failures motivated him to invent the first error correction code, turning parity checks into a method for locating errors.
Summary & Key Takeaways
-
Error correction works by restricting transmitted or stored blocks to a subset of valid messages. If noise changes a valid message, the receiver tries to identify the nearest valid block, much like correcting a misspelled word. The central challenge is building an efficient system that provides resilience while consuming little space for redundancy.
-
A parity bit is adjusted so a chosen group contains an even number of 1s. One flipped bit changes that group to odd parity, revealing that an error occurred without identifying its location. Two flips preserve even parity, so a single parity check cannot reliably detect every possible pattern of errors.
-
Hamming's key insight was to perform several parity checks on carefully selected subsets instead of checking only the complete block. Each check supplies a yes-or-no clue about the error's location. Together, these clues narrow the possibilities until a receiver can identify and correct any single flipped bit within the block.
Read in Other Languages (beta)
Share This Summary 📚
Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator
Explore More Summaries from 3Blue1Brown 📚






Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator