Channel Capacity
The capacity of a channel is the largest mutual information between input and output that any input distribution can achieve:
The noisy-channel coding theorem gives this number its meaning: it is the highest rate, in bits per channel use, at which information can be sent with arbitrarily small error probability (The Noisy-Channel Coding Theorem).
Capacities of standard channels
| Channel | Capacity | Achieving input |
|---|---|---|
| noiseless binary | 1 bit | uniform |
| binary symmetric, flip | uniform | |
| binary erasure, erasure | uniform | |
| noisy typewriter with keys | uniform | |
| Z channel, | about 0.685 |
import numpy as np
from scipy.optimize import minimize_scalar
def channel_mi(px, Q):
py = px @ Q; joint = px[:, None] * Q; nz = joint > 0
return float(np.sum(joint[nz] * np.log2((Q / np.where(py > 0, py, 1))[nz])))
def binary_capacity(Q):
res = minimize_scalar(lambda p: -channel_mi(np.array([1 - p, p]), Q), bounds=(0, 1), method="bounded",
options={"xatol": 1e-10})
return -res.fun, res.x
H2 = lambda f: -f * np.log2(f) - (1 - f) * np.log2(1 - f)
for name, Q, formula in [("BSC f=0.1", np.array([[0.9, 0.1], [0.1, 0.9]]), 1 - H2(0.1)),
("BEC e=0.2", np.array([[0.8, 0.2, 0], [0, 0.2, 0.8]]), 0.8),
("Z f=0.15", np.array([[1.0, 0.0], [0.15, 0.85]]), None)]:
C, p = binary_capacity(Q)
extra = f" formula {formula:.4f}" if formula is not None else ""
print(f"{name:10s}: C = {C:.4f} at P(X=1) = {p:.3f}{extra}")BSC f=0.1 : C = 0.5310 at P(X=1) = 0.500 formula 0.5310
BEC e=0.2 : C = 0.8000 at P(X=1) = 0.500 formula 0.8000
Z f=0.15 : C = 0.6854 at P(X=1) = 0.445
Symmetric channels
A channel is symmetric if all rows are permutations of each other and all columns are permutations of each other. Then is the same for every input, equal to the entropy of one row, and uniform input makes the output uniform, so
import numpy as np
def channel_mi(px, Q):
py = px @ Q; joint = px[:, None] * Q; nz = joint > 0
return float(np.sum(joint[nz] * np.log2((Q / np.where(py > 0, py, 1))[nz])))
# a 4-ary symmetric channel: correct with prob 0.7, each other symbol with prob 0.1
Q = np.full((4, 4), 0.1) + np.eye(4) * 0.6
row = Q[0]
print("formula: ", round(np.log2(4) + float(np.sum(row * np.log2(row))), 4))
print("uniform MI:", round(channel_mi(np.ones(4) / 4, Q), 4))
rng = np.random.default_rng(0)
print("best of 5000 random inputs:", round(max(channel_mi(rng.dirichlet(np.ones(4)), Q) for _ in range(5000)), 4))formula: 0.6432
uniform MI: 0.6432
best of 5000 random inputs: 0.6431
Properties of capacity
- .
- exactly when the output is independent of the input for every input distribution.
- Capacity is a maximum of a concave function over the probability simplex, so it can be computed reliably by convex optimization or by the Blahut-Arimoto algorithm (Computing Capacity: Blahut-Arimoto).
- Feedback (the transmitter seeing what was received) does not increase the capacity of a memoryless channel, though it can make coding much simpler.
Using a channel many times
For independent uses of a channel, the capacity of the combined channel is . Capacity is additive, which is why it is quoted per use.
import numpy as np
from itertools import product
def channel_mi(px, Q):
py = px @ Q; joint = px[:, None] * Q; nz = joint > 0
return float(np.sum(joint[nz] * np.log2((Q / np.where(py > 0, py, 1))[nz])))
Q = np.array([[0.9, 0.1], [0.1, 0.9]])
Q2 = np.kron(Q, Q) # two uses: inputs 00, 01, 10, 11
print("one use, uniform input:", round(channel_mi(np.ones(2) / 2, Q), 4))
print("two uses, uniform input:", round(channel_mi(np.ones(4) / 4, Q2), 4))one use, uniform input: 0.531
two uses, uniform input: 1.062
In software
- For binary-input channels, a bounded scalar optimizer over is enough. For larger alphabets use Blahut-Arimoto or a convex solver over the simplex.
- Link budgets in communications compare the data rate needed with the capacity; a rate above capacity is impossible to support reliably, whatever the code.
Exercises
Exercise 1: Erasure channel
What is the capacity of a binary erasure channel that loses 30% of bits?
Answer
0.7 bits per use.
Solution
. Intuitively, the 70% of bits that arrive are perfect, and the transmitter cannot know in advance which ones will be lost.
Exercise 2: Typewriter
What is the capacity of a 26-key noisy typewriter, where each key produces itself or the next letter with probability ?
Answer
bits.
Solution
. It is achieved without any errors by using only every second key: those 13 keys produce disjoint output pairs.
Exercise 3: A ternary channel (code)
Find the capacity of the channel with rows , , by random search over input distributions.
Answer
About 0.827 bits, with input probabilities about : the noisy middle symbol is used rarely.
Solution
import numpy as np
def channel_mi(px, Q):
py = px @ Q; joint = px[:, None] * Q; nz = joint > 0
return float(np.sum(joint[nz] * np.log2((Q / np.where(py > 0, py, 1))[nz])))
Q = np.array([[0.8, 0.2, 0.0], [0.1, 0.8, 0.1], [0.0, 0.2, 0.8]])
rng = np.random.default_rng(1)
cands = rng.dirichlet(np.ones(3), size=20000)
vals = np.array([channel_mi(p, Q) for p in cands])
print(round(vals.max(), 3), np.round(cands[vals.argmax()], 2))0.827 [0.43 0.14 0.43]
Test yourself
Channel capacity is defined as…
- the maximum of over input distributions
- the mutual information for uniform input
- the minimum error probability
The capacity of a binary erasure channel with erasure probability e is…
For n independent uses of a channel with capacity C, the total capacity is…
- nC
- C