📡 Noisy Channel Lab: Shannon Capacity, Repetition and Hamming Error Correction

The science

Channel. Binary symmetric channel: each bit flips independently with probability p. Noise entropy H(p) = -p log2 p - (1-p) log2 (1-p); capacity C = 1 - H(p) bits per channel use (Shannon, 1948).

Codes. Uncoded: bit error rate (BER) = p. Repetition-3 (rate 1/3), majority vote: BER = 3p^2(1-p) + p^3 = 3p^2 - 2p^3. Hamming(7,4) (rate 4/7): corrects any single flip in a 7-bit block with a 3-bit syndrome; it is a perfect code, so a block fails exactly when 2 or more of 7 bits flip: P_fail = 1 - (1-p)^7 - 7p(1-p)^6.

Shannon's theorem. For any rate R < C there exist codes with error probability going to 0 as block length grows; for R > C none do. The codes here are short, so their errors do not vanish: repetition-3 pays rate 1/3 for a modest gain, and neither reaches the capacity line. Modern LDPC and turbo codes approach it.

Checks on this page. Monte-Carlo (4e5 trials, 4-sigma tolerance) against the closed forms above, and the empirical entropy of the flip sequence against H(0.1). The "Hamming exact" curve is an enumeration of all 128 error patterns through the same decoder.

Simplifications. Memoryless random noise, one bit at a time, no synchronisation or bursts; the title's "omniscient" idea is read as a receiver that knows the code and p perfectly. ASCII text is only a visual aid.

What you are looking at

A message is turned into bits, sent over a channel that flips each bit with probability p, and decoded. Statistics are collected for all three codes at once. Raise the noise until the code rate passes the Shannon capacity and reliable communication becomes impossible.

Presets

Parameters

x1

Live readouts

Independent numerical checks