The Noisy-Channel Coding Theorem
Before 1948 engineers believed that to make errors rarer you had to send more slowly: repeat each bit more often, and the rate goes to zero as the error rate does. Shannon proved this is wrong. Every channel has a capacity , and at any rate below there are codes whose error probability is as small as you like.
Codes, rates and errors
An block code maps one of messages to a codeword of channel inputs. Its rate is
The decoder maps the received symbols back to a message. The block error probability is the probability that the decoded message is wrong.
The theorem
For a discrete memoryless channel with capacity :
- Achievability: for every rate and every there is, for large enough , a code of rate at least with block error probability below .
- Converse: at rates , the error probability is bounded away from zero for every code. More precisely, the bit error rate achievable at rate satisfies .
import numpy as np
H2 = lambda p: 0.0 if p <= 0 else float(-p * np.log2(p) - (1 - p) * np.log2(1 - p))
f = 0.1
C = 1 - H2(f)
print(f"BSC f = {f}: capacity C = {C:.4f}")
print("highest achievable rate for a target bit error rate pb:")
for pb in [0.1, 0.05, 0.01, 1e-3, 1e-6]:
print(f" pb = {pb:g}: R_max = {C / (1 - H2(pb)):.4f}")BSC f = 0.1: capacity C = 0.5310
highest achievable rate for a target bit error rate pb:
pb = 0.1: R_max = 1.0000
pb = 0.05: R_max = 0.7441
pb = 0.01: R_max = 0.5777
pb = 0.001: R_max = 0.5371
pb = 1e-06: R_max = 0.5310
At bit error rate , the maximum rate is essentially . Allowing more errors buys a little extra rate; at you can send uncoded bits at rate 1.
The achievable region
Plotting rate against bit error rate splits the plane into what is possible and what is not. Repetition codes sit far inside the possible region, close to the axis: their rate goes to zero as their error rate does.
import numpy as np
from scipy.stats import binom
H2 = lambda p: 0.0 if p <= 0 else float(-p * np.log2(p) - (1 - p) * np.log2(1 - p))
f = 0.1; C = 1 - H2(f)
print("repetition codes R_N on a BSC with f = 0.1:")
for N in [1, 3, 5, 9, 15, 25]:
pb = binom.sf(N // 2, N, f) # majority vote fails if more than N/2 bits flip
limit = C / (1 - H2(pb))
print(f" N = {N:2d}: rate {1 / N:.3f}, pb = {pb:.2e}, Shannon allows rate up to {limit:.3f} at this pb")repetition codes R_N on a BSC with f = 0.1:
N = 1: rate 1.000, pb = 1.00e-01, Shannon allows rate up to 1.000 at this pb
N = 3: rate 0.333, pb = 2.80e-02, Shannon allows rate up to 0.651 at this pb
N = 5: rate 0.200, pb = 8.56e-03, Shannon allows rate up to 0.572 at this pb
N = 9: rate 0.111, pb = 8.91e-04, Shannon allows rate up to 0.537 at this pb
N = 15: rate 0.067, pb = 3.36e-05, Shannon allows rate up to 0.531 at this pb
N = 25: rate 0.040, pb = 1.62e-07, Shannon allows rate up to 0.531 at this pb
To get below a repetition code needs rate , while the theorem promises codes with rate 0.53. The rest of the course looks at how real codes close this gap (Repetition Codes, Low-Density Parity-Check Codes).
Why it is surprising, and why it works
The proof does not construct a good code. It shows that a randomly chosen code is good on average, using typical sets: the received word is almost surely jointly typical with the transmitted codeword, and the chance that some other random codeword is also jointly typical is about per codeword. With codewords this vanishes when (Random Codes and Typical-Set Decoding). The converse uses Fano's inequality and the data-processing inequality (Why You Cannot Beat Capacity).
Two ingredients are essential: long blocks (so that the law of large numbers makes the noise predictable in aggregate) and sparse codebooks (only of the possible words are used, leaving room around each codeword).
In software
- 5G, Wi-Fi 6 and DVB-S2 use LDPC and polar codes that operate within about 1 dB of the Shannon limit on Gaussian channels.
- Storage systems (SSDs, hard disks) also use LDPC codes; the "Shannon limit" sets how dense the bits can be packed for a given raw error rate.
Exercises
Exercise 1: Rate of a code
A code maps 4 data bits to 7 channel bits. What is its rate? Is it usable on a BSC with at low error probability, in principle?
Answer
Rate ; no, it exceeds the capacity 0.531.
Solution
, so by the converse no code of this rate (of any length) can get the error probability close to zero on this channel. Its errors can still be reduced compared with sending uncoded bits.
Exercise 2: Messages and length
How many messages can a code of rate 0.5 and length 1000 carry?
Answer
.
Solution
.
Exercise 3: Rate for a target error (code)
On a BSC with , what is the highest possible rate if a bit error rate of is acceptable?
Answer
About 0.722 bits per use, slightly above the capacity 0.714.
Solution
import numpy as np
H2 = lambda p: -p * np.log2(p) - (1 - p) * np.log2(1 - p)
C = 1 - H2(0.05)
print(round(C, 4), round(C / (1 - H2(1e-3)), 4))0.7136 0.7218
Test yourself
The noisy-channel coding theorem says that below capacity…
- the error probability can be made arbitrarily small at a fixed positive rate
- the rate must go to zero for reliability
- errors are impossible without coding
- only repetition codes work
The rate of a code with M codewords of length n is…
Shannon's proof of achievability uses…
- random codes and typical-set decoding
- Hamming codes
- Huffman trees
- the Kraft inequality