Error Coding
A flipped bit, three codes respond
The blue cells are the received data bits, the gold cells are the appended check bits, and the cell with the red border is the bit flipped by noise. Press No code, Parity, and Hamming in turn to compare how the three codes handle the same single-bit error. With data alone the error goes unnoticed, a single parity bit only notices that something is wrong, and Hamming points to the exact bit and fixes it.
Noise flips bits
Noise at the receiver occasionally turns a 0 into a 1 or a 1 into a 0. In the plot the original data is 1011, but its second bit flipped and it arrived as 1111. Had only the data bits been sent, 1111 would look like perfectly good 4-bit data, and the receiver would have no way to tell that an error even happened. Every bit pattern is equally plausible as data.
Extra bits stand guard
Append check bits computed from the data by a rule, and the situation changes. The simplest, a parity bit, is the XOR of all data bits, which always makes the count of 1s even. The original data 1011 has three 1s, so its parity is 1; when the second bit flips, the count becomes five 1s, an odd number, and the check fails. That tells the receiver an error occurred, but a single parity bit cannot say which bit is wrong.
Distance makes correction
Picture codewords as points: a good code keeps its valid points well apart. The number of bit positions in which two codewords differ is called the Hamming distance; if the minimum distance between valid codewords is 2, a single-bit error can be detected, and if it is 3, the error can even be corrected, because a word with one wrong bit still lies closest to its original codeword. Hamming (7,4) uses 3 check bits to locate an error in any one of the 7 bits. Each of the three check bits guards a different group of data bits, so the pattern of which checks fail points to a single flipped position. The price is a code rate R = k/n = 4/7: sending 4 bits of information costs 3 bits of overhead.
Back to the first screen
With no protection, the flipped bit passed for valid data and showed red. Adding one parity bit raised a signal that something was off, but not which bit, so it showed orange; when Hamming's check bits pooled their mismatches, pinpointed that bit, and flipped it back, it turned gold. One thing to remember: when extra bits keep valid words far apart, a word nudged one step by noise still returns to the nearest original. This is how the reliability below capacity that Shannon promised is actually kept.
Closing the communications track
Starting from why we modulate, this track has followed one message all the way along its path. The small swings of the baseband were loaded onto a carrier and lifted up the frequency axis (AM·FM), turned into numbers (sampling·PCM), and used as bits to shake a carrier (ASK·FSK·PSK). Then came the bandwidth ceiling, the measurement of noise and SNR, taming randomness with probability, Shannon's absolute limit, and finally codes that undo errors below that limit. Communication, in the end, is the art of handing a message across a noisy world without losing it.