The Gaussian Channel
The most important continuous channel adds Gaussian noise to a power-limited signal: with and average power . It models radio, cable and optical links, and its capacity formula, the Shannon-Hartley theorem, sets the speed limit of every modem.
Capacity
It is achieved by Gaussian inputs. The argument: ; the noise term is fixed, and is largest when is Gaussian, which happens when is Gaussian with variance (Differential Entropy). The ratio is the signal-to-noise ratio (SNR), often quoted in decibels: .
import numpy as np
for snr_db in [-10, 0, 3, 10, 20, 30]:
snr = 10 ** (snr_db / 10)
print(f"SNR {snr_db:4d} dB (ratio {snr:8.2f}): C = {0.5 * np.log2(1 + snr):.4f} bits per use")SNR -10 dB (ratio 0.10): C = 0.0688 bits per use
SNR 0 dB (ratio 1.00): C = 0.5000 bits per use
SNR 3 dB (ratio 2.00): C = 0.7913 bits per use
SNR 10 dB (ratio 10.00): C = 1.7297 bits per use
SNR 20 dB (ratio 100.00): C = 3.3291 bits per use
SNR 30 dB (ratio 1000.00): C = 4.9836 bits per use
At high SNR, each extra 6 dB (a factor of 4 in power) adds one bit per use. At low SNR, capacity is nearly proportional to power.
Bandwidth: the Shannon-Hartley theorem
A channel of bandwidth hertz can carry independent samples per second. With noise power spectral density , the noise power in the band is , so
import numpy as np
P_over_N0 = 1e6 # signal power / noise density, in Hz
for W in [1e3, 1e4, 1e5, 1e6, 1e7, 1e8]:
C = W * np.log2(1 + P_over_N0 / W)
print(f"W = {W:9.0f} Hz: C = {C / 1e3:9.1f} kbit/s")
print(f"limit as W grows: P/(N0 ln 2) = {P_over_N0 / np.log(2) / 1e3:.1f} kbit/s")W = 1000 Hz: C = 10.0 kbit/s
W = 10000 Hz: C = 66.6 kbit/s
W = 100000 Hz: C = 345.9 kbit/s
W = 1000000 Hz: C = 1000.0 kbit/s
W = 10000000 Hz: C = 1375.0 kbit/s
W = 100000000 Hz: C = 1435.5 kbit/s
limit as W grows: P/(N0 ln 2) = 1442.7 kbit/s
More bandwidth helps, but with diminishing returns: as , capacity tends to . Equivalently, reliable communication needs at least , about dB of energy per bit: the Shannon limit.
Binary inputs and hard decisions
Real systems often restrict inputs to (BPSK). That loses little at low SNR but caps capacity at 1 bit per use. Thresholding the output to a bit (a BSC) loses more:
import numpy as np
from scipy.stats import norm
from scipy.integrate import quad
def bpsk_soft_capacity(snr):
s = 1 / np.sqrt(snr) # amplitude 1, noise std s
def integrand(y):
p0, p1 = norm.pdf(y, 1, s), norm.pdf(y, -1, s)
return p0 * np.log2(2 * p0 / (p0 + p1))
return quad(integrand, 1 - 12 * s, 1 + 12 * s, limit=200)[0]
H2 = lambda f: -f * np.log2(f) - (1 - f) * np.log2(1 - f)
for snr_db in [-5, 0, 5, 10]:
snr = 10 ** (snr_db / 10)
f = norm.cdf(-np.sqrt(snr))
print(f"{snr_db:3d} dB: Gaussian input {0.5 * np.log2(1 + snr):.4f}, BPSK soft {bpsk_soft_capacity(snr):.4f}, "
f"BPSK hard {1 - H2(f):.4f}") -5 dB: Gaussian input 0.1982, BPSK soft 0.1977, BPSK hard 0.1353
0 dB: Gaussian input 0.5000, BPSK soft 0.4859, BPSK hard 0.3689
5 dB: Gaussian input 1.0287, BPSK soft 0.8592, BPSK hard 0.7685
10 dB: Gaussian input 1.7297, BPSK soft 0.9968, BPSK hard 0.9908
Keeping soft values instead of hard bits is worth about 2 dB at low SNR, which is why modern decoders work with log-likelihood ratios (Sum-Product (Belief Propagation) Decoding).
Parallel channels and water-filling
With several independent Gaussian channels of different noise levels (for example the subcarriers of OFDM in Wi-Fi and 4G/5G) and a total power budget, the best allocation is water-filling: pour power into the channels as water into a vessel whose floor is the noise level. Quiet channels get more power; very noisy channels may get none. This is a small convex optimization problem solved by its KKT conditions (The KKT Conditions).
import numpy as np
from scipy.optimize import brentq
noise = np.array([0.5, 1.0, 2.0, 4.0, 8.0])
P_total = 6.0
level = brentq(lambda mu: np.maximum(mu - noise, 0).sum() - P_total, 0, 100)
power = np.maximum(level - noise, 0)
C = 0.5 * np.log2(1 + power / noise).sum()
print("water level:", round(level, 4))
print("power per channel:", np.round(power, 4))
print(f"total capacity {C:.4f} bits; equal split gives {0.5 * np.log2(1 + P_total / 5 / noise).sum():.4f}")water level: 3.1667
power per channel: [2.6667 2.1667 1.1667 0. 0. ]
total capacity 2.4944 bits; equal split gives 2.0806
In software
- Modems pick a modulation and code rate from the measured SNR (adaptive coding and modulation), staying a few dB below the Shannon-Hartley limit.
- Water-filling appears in OFDM bit loading, in MIMO precoding over singular values of the channel matrix, and in rate-distortion for Gaussian sources (reverse water-filling).
Exercises
Exercise 1: Capacity at 15 dB
What is the capacity per use at SNR 15 dB?
Answer
About 2.51 bits.
Solution
, and .
Exercise 2: Doubling the power
At high SNR, how much does doubling the power increase the capacity per use?
Answer
About half a bit.
Solution
.
Exercise 3: A phone line (code)
A phone line has bandwidth 3100 Hz and SNR 35 dB. What is its Shannon capacity?
Answer
About 36 kbit/s.
Solution
import numpy as np
W, snr = 3100, 10 ** 3.5
print(round(W * np.log2(1 + snr) / 1000, 2), "kbit/s")36.04 kbit/s
This is why analog modems topped out around 33.6 kbit/s.
Test yourself
The capacity of the Gaussian channel per use is…
As bandwidth grows without limit at fixed power, capacity…
- approaches
- grows without limit
- drops to zero
- stays constant at any bandwidth
Water-filling gives more power to…
- the channels with less noise
- the channels with more noise
- all channels equally
- only one channel