Error-Correcting Codes Waterfall Lab

Add redundancy, survive noise: five ways to protect bits on a BPSK / AWGN link, measured against theory and the Shannon limit.
Live link
4.0 dB
Tip: click or tap a cell of the Received row to flip it yourself and see whether the decoder still recovers the message. Right-click a code button to hide its curve.
BER waterfall (Monte Carlo)
Points are measured here, in your browser, with a fixed seed. Dashed lines are theory: exact for repetition and Hamming, a union bound for the convolutional code. The grey dotted vertical line is the Shannon limit for the selected code's rate. Click the chart to set Eb/N0.
Status-Bits simulated0
Experiment: coding gain at a target BER
CodeRateTheory dBMeasured dBGain dB
Independent numerical checks
Running...
CheckResultReference
The science

Channel. Each coded bit is sent as BPSK, +1 or -1. The receiver sees r = s + n with Gaussian noise n ~ N(0, σ²), σ² = 1/(2 R Eb/N0), where R = k/n is the code rate. Coding spends energy on redundant bits, so at the same Eb/N0 every coded bit is noisier than an uncoded one. A hard decision (r < 0 means 1) turns this into a binary symmetric channel with flip probability p = Q(√(2 R Eb/N0)), Q(x) = ½ erfc(x/√2).

Uncoded BER is Q(√(2 Eb/N0)). Repetition of odd length n takes a majority vote: Pb = ∑k>n/2 C(n,k) pk(1-p)n-k. Because R = 1/n, each vote is noisier, so repetition is worse than no code at moderate SNR and only wins when SNR is high.

Hamming(7,4) has a parity-check matrix whose column j is the number j in binary, so the syndrome of a single error is the index of the flipped bit; it corrects any 1 error and miscorrects 2. Its theory curve is exact: all 128 error patterns are enumerated and weighted by pw(1-p)7-w.

Convolutional (7,5), K=3, R=1/2 keeps two bits of memory; the Viterbi algorithm finds the trellis path with the smallest total branch metric (Hamming distance for hard decisions, squared Euclidean distance for soft). Its free distance is 5. Union bound: Pb ≤ ∑d≥5 Bd Pd with Bd the total information weight of error events of distance d, found here by dynamic programming over the trellis (1, 4, 12, 32 ...). Soft: Pd = Q(√(2 d R Eb/N0)); hard: the binomial tail at p. Soft decisions typically buy about 2 dB over hard ones.

Shannon limit. For BPSK on AWGN, capacity is C = 1 - E[log2(1 + e-2Y/σ²)], Y ~ N(1,σ²). Setting C = R gives the lowest Eb/N0 at which any code of that rate can be reliable; the grey line is computed by numerical integration and bisection here. Rate 1/2 gives about 0.19 dB, and the absolute limit as R tends to 0 is -1.59 dB.

Simplifications. Convolutional blocks are 1000 information bits plus 2 zero tail bits (the tiny rate loss is ignored in Eb/N0). Monte Carlo points stop at 60 errors or a bit budget; a hollow marker means few or no errors were seen, so BER is only bounded above. The convolutional theory is a union bound, loose at low SNR where it saturates at 0.5. Convolutional decoding errors arrive in bursts (one wrong path gives several wrong bits), so points with few errors are noisier than a simple binomial estimate suggests. Real systems add interleaving, longer constraint lengths, turbo/LDPC codes and synchronisation, all outside this model. Known tabulated values quoted in the checks (Q-function table, 0.19 dB and -1.59 dB limits, the weight spectrum 1, 4, 12, 32) are typical textbook numbers and are cross-checked by independent computation on this page.