Noisy Channels
A channel is anything that carries information from one place to another and may corrupt it on the way: a radio link, a disk that stores bits for years, a scratched DVD, a DNA sequence copied in a cell. Information theory models every channel the same way, as a conditional probability table, and asks how many bits per use it can carry reliably.
The discrete memoryless channel
A discrete memoryless channel (DMC) has an input alphabet , an output alphabet , and transition probabilities . "Memoryless" means each use is independent of the others:
We store as a matrix with one row per input and one column per output; every row sums to 1.
import numpy as np
channels = {
"binary symmetric (f=0.1)": np.array([[0.9, 0.1], [0.1, 0.9]]),
"binary erasure (e=0.2)": np.array([[0.8, 0.2, 0.0], [0.0, 0.2, 0.8]]), # outputs 0, ?, 1
"Z channel (f=0.15)": np.array([[1.0, 0.0], [0.15, 0.85]]),
"noisy typewriter (3 keys)": np.array([[0.5, 0.5, 0.0], [0.0, 0.5, 0.5], [0.5, 0.0, 0.5]]),
}
for name, Q in channels.items():
print(f"{name:26s} rows sum to 1: {np.allclose(Q.sum(axis=1), 1)}, shape {Q.shape}")binary symmetric (f=0.1) rows sum to 1: True, shape (2, 2)
binary erasure (e=0.2) rows sum to 1: True, shape (2, 3)
Z channel (f=0.15) rows sum to 1: True, shape (2, 2)
noisy typewriter (3 keys) rows sum to 1: True, shape (3, 3)
| Channel | What happens |
|---|---|
| binary symmetric (BSC) | each bit flips with probability |
| binary erasure (BEC) | each bit is lost (received as ?) with probability , otherwise correct |
| Z channel | 0 is always received correctly; 1 turns into 0 with probability |
| noisy typewriter | each key produces itself or its neighbour, half the time each |
Simulating a channel
Sending a sequence through a DMC means sampling each output from the row of its input:
import numpy as np
rng = np.random.default_rng(0)
Q = np.array([[0.9, 0.1], [0.1, 0.9]]) # BSC with f = 0.1
x = rng.integers(0, 2, 20)
cum = np.cumsum(Q, axis=1)
y = (rng.random(x.size)[:, None] > cum[x]).sum(axis=1)
print("sent: ", "".join(map(str, x)))
print("received:", "".join(map(str, y)))
print("errors at positions:", np.nonzero(x != y)[0].tolist())sent: 11100000011111111111
received: 10100000010111111111
errors at positions: [1, 10]
Decoding is inference
The receiver sees and must guess . With a prior over inputs, Bayes' theorem gives the posterior (Bayes' Theorem):
The maximum a posteriori (MAP) decoder picks the most probable ; with uniform inputs this is the maximum-likelihood decoder, which picks the with the largest .
import numpy as np
Q = np.array([[1.0, 0.0], [0.15, 0.85]]) # Z channel
for prior in ([0.5, 0.5], [0.1, 0.9]):
joint = np.array(prior)[:, None] * Q
post = joint / joint.sum(axis=0)
print(f"prior {prior}: P(x | y=0) = {np.round(post[:, 0], 4)}, P(x | y=1) = {np.round(post[:, 1], 4)}")prior [0.5, 0.5]: P(x | y=0) = [0.8696 0.1304], P(x | y=1) = [0. 1.]
prior [0.1, 0.9]: P(x | y=0) = [0.4255 0.5745], P(x | y=1) = [0. 1.]
Receiving a 1 on the Z channel proves a 1 was sent. Receiving a 0 is ambiguous, and how ambiguous depends on the prior.
How much gets through?
The information the output carries about the input is the mutual information , which depends on both the channel and the input distribution (Information Through a Channel). Maximizing it over input distributions gives the capacity (Channel Capacity).
In software
- Simulating channels with
rng.randomcomparisons against cumulative row sums works for any DMC; for the BSC,x ^ (rng.random(n) < f)is enough. - Real links are often modelled as a continuous Gaussian channel followed by a quantizer (The Gaussian Channel); burst errors (scratches, fading) violate the memoryless assumption, and interleaving is used to spread them out.
Exercises
Exercise 1: Rows and columns
A channel has 4 inputs and 3 outputs. What shape is its transition matrix, and what must each row sum to?
Answer
; each row sums to 1.
Solution
Row is the distribution of the output for that input.
Exercise 2: Output distribution
For the BSC with and inputs , what is ?
Answer
0.34.
Solution
. In matrix form, .
Exercise 3: Erasure decoding (code)
Simulate 100,000 uses of a binary erasure channel with and count the fraction of erasures and of wrong (non-erased) outputs.
Answer
About 20% erasures and no wrong outputs.
Solution
import numpy as np
rng = np.random.default_rng(1)
x = rng.integers(0, 2, 100_000)
erased = rng.random(x.size) < 0.2
y = np.where(erased, -1, x) # -1 stands for '?'
print("erasures:", round(float(erased.mean()), 4), " wrong:", int(np.sum((y != -1) & (y != x))))erasures: 0.1996 wrong: 0
Test yourself
In a channel matrix with rows indexed by the input, each row is…
- the output distribution for that input
- the input distribution
- the posterior over inputs
- a codeword
A memoryless channel is one where…
- each use is independent given its input
- the output never depends on the input
- the channel forgets the codebook
- errors come in bursts
With uniform input probabilities, the MAP decoder becomes…
- the maximum-likelihood decoder
- a random guess
- the minimum-entropy decoder
- the erasure decoder