TExcelTAD
Home › Information Theory › Erasure and Z Channels

Erasure and Z Channels

The binary symmetric channel treats both bits alike and hides where the errors are. Two other binary channels are just as important: the erasure channel, where the receiver knows which bits were lost, and the Z channel, where only one of the two symbols can be corrupted. Both model real systems (lost packets, optical receivers, flash memory) and both show how much the kind of noise matters.

The binary erasure channel

Each bit arrives intact with probability 1−e1 - e or is replaced by an erasure symbol ? with probability ee:

Q=[1−ee00e1−e](outputs 0,?,1)Q = \begin{bmatrix} 1 - e & e & 0 \\ 0 & e & 1 - e \end{bmatrix} \quad (\text{outputs } 0, ?, 1)

Its capacity is C=1−eC = 1 - e, with uniform input. The proof is short: H(X∣Y)=e H(X)H(X \mid Y) = e\,H(X) because an erasure leaves the input as uncertain as before and anything else reveals it, so I(X;Y)=(1−e)H(X)I(X; Y) = (1 - e)H(X), maximized by H(X)=1H(X) = 1.

python · try it yourself
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])))

H2 = lambda f: -f * np.log2(f) - (1 - f) * np.log2(1 - f)
for e in [0.05, 0.1, 0.2, 0.5]:
    bec = np.array([[1 - e, e, 0], [0, e, 1 - e]])
    print(f"e = {e:4.2f}: BEC capacity {channel_mi(np.ones(2) / 2, bec):.4f},  BSC with f = e/2: {1 - H2(e / 2):.4f}")
e = 0.05: BEC capacity 0.9500,  BSC with f = e/2: 0.8313
e = 0.10: BEC capacity 0.9000,  BSC with f = e/2: 0.7136
e = 0.20: BEC capacity 0.8000,  BSC with f = e/2: 0.5310
e = 0.50: BEC capacity 0.5000,  BSC with f = e/2: 0.1887

An erasure is "half an error" in raw terms (a random guess is wrong half the time), yet the erasure channel is much better than a BSC with flip probability e/2e/2: knowing where the damage is helps enormously.

Coding for the erasure channel

On the Internet, packets either arrive intact or are lost, which is an erasure channel on packets. Erasure codes recover lost data by solving linear equations: with a random linear code, any kk received combinations of kk source symbols almost always suffice. Fountain codes (LT, Raptor) do this at very low cost.

python · try it yourself
import numpy as np

def gf2_rank(M):
    M = M.copy() % 2; r = 0
    for c in range(M.shape[1]):
        piv = np.nonzero(M[r:, c])[0]
        if len(piv) == 0:
            continue
        p = r + piv[0]; M[[r, p]] = M[[p, r]]
        for i in range(M.shape[0]):
            if i != r and M[i, c]:
                M[i] ^= M[r]
        r += 1
        if r == M.shape[0]:
            break
    return r

rng = np.random.default_rng(0)
k = 50
for extra in [0, 2, 5, 10]:
    ok = sum(gf2_rank(rng.integers(0, 2, (k + extra, k))) == k for _ in range(200))
    print(f"receive k + {extra:2d} random combinations: decodable in {ok / 200:.0%} of trials")
receive k +  0 random combinations: decodable in 26% of trials
receive k +  2 random combinations: decodable in 78% of trials
receive k +  5 random combinations: decodable in 96% of trials
receive k + 10 random combinations: decodable in 100% of trials

A few extra packets beyond kk make decoding almost certain, whichever packets were lost.

The Z channel

A 0 is always received as 0; a 1 turns into 0 with probability ff:

Q=[10f1−f]Q = \begin{bmatrix} 1 & 0 \\ f & 1 - f \end{bmatrix}

Examples: an optical link where a pulse can be missed but darkness is never mistaken for light, or a memory cell that can leak charge but never gain it. Because 1s are the fragile symbol, the optimal input uses them less than half the time.

python · try it yourself
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])))

for f in [0.05, 0.15, 0.3, 0.5]:
    Z = np.array([[1.0, 0.0], [f, 1 - f]])
    res = minimize_scalar(lambda p: -channel_mi(np.array([1 - p, p]), Z), bounds=(0, 1), method="bounded",
                          options={"xatol": 1e-10})
    print(f"f = {f:4.2f}: C = {-res.fun:.4f} at P(X=1) = {res.x:.3f};  uniform input gives {channel_mi(np.ones(2) / 2, Z):.4f}")
f = 0.05: C = 0.8571 at P(X=1) = 0.472;  uniform input gives 0.8550
f = 0.15: C = 0.6854 at P(X=1) = 0.445;  uniform input gives 0.6788
f = 0.30: C = 0.5037 at P(X=1) = 0.421;  uniform input gives 0.4934
f = 0.50: C = 0.3219 at P(X=1) = 0.400;  uniform input gives 0.3113

Even at f=0.5f = 0.5, where half of all 1s are lost, the Z channel still carries about 0.32 bits per use.

Comparing the three

Channel Noise Capacity at noise 0.1
BSC flips, location unknown 0.531
Z one-sided flips about 0.763
BEC losses, location known 0.9

In software

  • Packet networks use erasure codes (Reed-Solomon, RaptorQ in RFC 6330) because lost packets are detected by sequence numbers and checksums (Error Detection and CRCs).
  • RAID 5 and 6 are erasure codes over disks: a failed disk is a known erasure.

Exercises

Exercise 1: Erasures vs flips

A link loses 20% of bits (known positions). Another flips 20% (unknown positions). Compare their capacities.

Answer

0.8 versus about 0.278 bits per use.

Solution

BEC: 1−0.2=0.81 - 0.2 = 0.8. BSC: 1−H2(0.2)=1−0.722=0.2781 - H_2(0.2) = 1 - 0.722 = 0.278.

Exercise 2: Decoding an erasure

With the single-parity code (3 data bits plus their XOR), the receiver gets 1 ? 0 1. What was the missing bit?

Answer
Solution

All four bits XOR to 0, so the missing bit is 1⊕0⊕1=01 \oplus 0 \oplus 1 = 0. A single parity bit can fill in any one erasure.

Exercise 3: Z channel at f = 0.1 (code)

Compute the capacity of the Z channel with f=0.1f = 0.1 and the optimal P(X=1)P(X = 1).

Answer

About 0.763 bits at P(X=1)≈0.456P(X = 1) \approx 0.456.

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

Z = np.array([[1.0, 0.0], [0.1, 0.9]])
res = minimize_scalar(lambda p: -channel_mi(np.array([1 - p, p]), Z), bounds=(0, 1), method="bounded", options={"xatol": 1e-10})
print(round(-res.fun, 4), round(res.x, 3))
0.7628 0.456

Test yourself

Why is an erasure channel better than a BSC with the same raw error rate?

  1. The receiver knows where the damage is
  2. Erasures are rarer
  3. It has more output symbols for free
  4. It uses non-uniform input

The capacity-achieving input of a Z channel sends 1s…

  1. less than half the time
  2. exactly half the time
  3. more than half the time
  4. never

Packet loss on the Internet is best modelled as…

  1. an erasure channel
  2. a BSC
  3. a Z channel
  4. a noiseless channel