Hamming Bound — Definition, Formula & Example
The Hamming bound is an upper limit on how many codewords an error-correcting code can contain, given its word length and the number of errors it must correct. It comes from requiring that the error-correction zones around codewords never overlap.
Let be a code of length over an alphabet of size with minimum Hamming distance , and let . The Hamming balls of radius centered at the codewords are pairwise disjoint. Each ball contains words, and there are only words in total, so cannot exceed divided by the ball size. A code that meets the bound with equality is called a perfect code. The bound limits the size of every code but does not guarantee that a code of that size exists.
Key Formula
Where:
- = number of codewords in the code
- = alphabet size (q = 2 for binary codes)
- = length of each codeword
- = minimum Hamming distance between any two distinct codewords
- = number of errors the code can always correct
- = number of words at distance exactly i from a fixed codeword
Worked Example
Problem: A binary code has codewords of length 7, and any two codewords differ in at least 3 positions. Use the Hamming bound to find an upper bound on the number of codewords.
Step 1: Find how many errors the code can correct. With :
Step 2: Count the words in a Hamming ball of radius 1 around a codeword. For , the factor equals 1. The ball holds the codeword itself plus the 7 words that differ from it in one position.
Step 3: There are binary words of length 7. Since the balls cannot overlap, divide the total by the ball size.
Answer: The Hamming bound gives . This bound happens to be achieved: the Hamming code has exactly 16 codewords, so it is a perfect code, and 16 is the largest possible size for these parameters.
Why It Matters
In a coding theory course, the Hamming bound is the first test you apply to a proposed code: if the parameters violate it, no such code exists. It also defines perfect codes, such as the Hamming codes and the binary Golay code of length 23. These codes waste no space, which is why Hamming codes are used in ECC computer memory.
Common Mistakes
Mistake: Using the minimum distance as the ball radius instead of .
Correction: The disjoint balls have radius , the number of correctable errors. With , use radius 1, not 3. Using makes the balls too large and gives a bound that is not valid.
