TExcelTAD
Home › Information Theory › Noisy Channels

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 AX\mathcal{A}_X, an output alphabet AY\mathcal{A}_Y, and transition probabilities Q(y∣x)Q(y \mid x). "Memoryless" means each use is independent of the others:

P(y1,…,yn∣x1,…,xn)=∏i=1nQ(yi∣xi)P(y_1, \dots, y_n \mid x_1, \dots, x_n) = \prod_{i=1}^n Q(y_i \mid x_i)

We store QQ as a matrix with one row per input and one column per output; every row sums to 1.

python · try it yourself
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 ff
binary erasure (BEC) each bit is lost (received as ?) with probability ee, otherwise correct
Z channel 0 is always received correctly; 1 turns into 0 with probability ff
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:

python · try it yourself
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 yy and must guess xx. With a prior P(x)P(x) over inputs, Bayes' theorem gives the posterior (Bayes' Theorem):

P(x∣y)=Q(y∣x)P(x)∑x′Q(y∣x′)P(x′)P(x \mid y) = \frac{Q(y \mid x)P(x)}{\sum_{x'} Q(y \mid x')P(x')}

The maximum a posteriori (MAP) decoder picks the most probable xx; with uniform inputs this is the maximum-likelihood decoder, which picks the xx with the largest Q(y∣x)Q(y \mid x).

python · try it yourself
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 I(X;Y)I(X; Y), 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.random comparisons 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

4×34 \times 3; each row sums to 1.

Solution

Row xx is the distribution Q(⋅∣x)Q(\cdot \mid x) of the output for that input.

Exercise 2: Output distribution

For the BSC with f=0.1f = 0.1 and inputs P(X=1)=0.3P(X = 1) = 0.3, what is P(Y=1)P(Y = 1)?

Answer

0.34.

Solution

0.3×0.9+0.7×0.1=0.27+0.07=0.340.3 \times 0.9 + 0.7 \times 0.1 = 0.27 + 0.07 = 0.34. In matrix form, PY=PXQP_Y = P_X Q.

Exercise 3: Erasure decoding (code)

Simulate 100,000 uses of a binary erasure channel with e=0.2e = 0.2 and count the fraction of erasures and of wrong (non-erased) outputs.

Answer

About 20% erasures and no wrong outputs.

Solution
python · try it yourself
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…

  1. the output distribution for that input
  2. the input distribution
  3. the posterior over inputs
  4. a codeword

A memoryless channel is one where…

  1. each use is independent given its input
  2. the output never depends on the input
  3. the channel forgets the codebook
  4. errors come in bursts

With uniform input probabilities, the MAP decoder becomes…

  1. the maximum-likelihood decoder
  2. a random guess
  3. the minimum-entropy decoder
  4. the erasure decoder