# What is the cost of Hamming coding?

We know that (7,4) hamming code has 4 message bits and 7 code bits and can detect any single bit error. The (12,4) repetition code has 4 message bits and 12 code bits and can detect any single bit error. I tend to think that since in hamming code we are using less number of parity bits, there should be some disadvantage vis a vis repetition code. Is it true and if yes, what is the downside of hamming code? (One known disadvantage is that of encoding and decoding complexity.)

This is an important subject that (IMO) is poorly handled in many introductory textbooks. To start, assume that an uncoded system spends $E_b$ joules per bit and transmits at rate $R_p$ information bits per second.

How can you compare this system fairly with the Hamming (7,4) code? Making them operate at the same bit rate implies a bandwidth expansion of 7/4, which is not always possible or desirable. Making them operate at the same energy per bit means that the energy of each Hamming coded bit should be $E_c=4E_b/7$.

So, you could say: under the same bandwidth and energy constraints, the cost of using a Hamming (7,4) code is a reduction in the data rate by a factor of 7/4. The benefit is a slight reduction in bit-error probabilty (but quite a bit less than that predicted by the binary symmetric channel).

Regarding the repetition code: under the same assumptions, the repetion code has a rate reduction of a factor of 3, while offering zero gain in probability of error!

Under the assumption that $E_c=E_b$, then the repetition code has quite a bit to offer in terms of bit-error rate. However, the cost is that you're multiplying the energy consumption by 3 while reducing your data rate by 3. To be fair, you'd need to compare the repetion code with an uncoded system whose $E_b$ is also increased by a factor of 3.

To summarize: comparing codes is not trivial, but not terribly hard either, as long as you make all your assumptions clear.

• "Regarding the repetition code: under the same assumptions, the repetion code has a rate reduction of a factor of 3, while offering zero gain in probability of error! Under the assumption that Ec=Eb, then the repetition code has quite a bit to offer in terms of bit-error rate. " I did not understand the "zero gain" point. What do you mean? Repetition code also improves BER by error correction. Commented Apr 15, 2016 at 0:34
• In rep code, if you are increasing the energy consumption by a factor of 3, you are not reducing the data rate because you are sending 3x bits now in one second instead of x per second in uncoded. That is why your energy consumption is increasing by a factor of 3. Commented Apr 15, 2016 at 0:40
• What I'm saying is that repetition codes are useless when you keep the energy per information bit equal. You can try it out by yourself: find the BER of a (3,1) code with $E_c=1/3$ and compare to BPSK with $E_b=1$. You'll see they have the same BER. Repetition codes only work over the BSC. Also: if you want to keep the data rate the same, you need to expand your bandwidth.
– MBaz
Commented Apr 15, 2016 at 0:44
• So what you are saying is that Rep code is of no use, if you keep energy constant whereas Hamming code has advantage. Are we missing any thing in Hamming other than the increased complexity is what I am trying to think of? Commented Apr 15, 2016 at 1:02
• Please help me see how to make my answer clearer: with Hamming codes, besides the extra complexity you either lose data rate (if you keep the bandwidth constant) or you have to expand the bandwidth (if you keep the data rate the same).
– MBaz
Commented Apr 15, 2016 at 1:19