Claude Shannon and Information Theory

Claude Shannon (1916–2001) was an American mathematician and electrical engineer whose 1948 paper A Mathematical Theory of Communication founded the field of information theory — a framework for quantifying, storing, and transmitting information that underpins every digital system ever built. It matters profoundly to modern AI because the mathematical tools Shannon invented — entropy, mutual information, channel capacity — appear directly inside loss functions, compression algorithms, and the training objectives of neural networks. The counterintuitive fact: Shannon proved there is a hard mathematical limit to how efficiently information can be compressed, and another hard limit to how reliably it can be transmitted through a noisy channel — and both limits are achievable, even if you can never exceed them.

The core insight

Information is a measurable physical quantity — just like mass or temperature — and the right unit to measure it in is the bit. The key insight is that "surprise" and "information" are the same thing: a message you were almost certain to receive carries almost no information, while a shocking, unexpected message carries a lot. Shannon made this precise: the rarer an event, the more information its occurrence conveys. This single idea connects probability directly to communication, compression, and — decades later — to how neural networks learn.

How It Works

At the heart of information theory is a deceptively simple formula. Suppose you have a source that produces messages drawn from an alphabet of symbols, each with some probability. Shannon asked: on average, how many bits do you need to encode one symbol?

1
H(X)=−∑ipilog⁡2(pi)\quad H(X) = -\sum_{i} p_i \log_2(p_i)

Explanation: This is Shannon entropy — it computes the average number of bits needed to represent one symbol from source X, weighted by how often each symbol actually appears.

Symbols:

  • H(X)H(X) — entropy of random variable XX, measured in bits
  • pip_i — probability of the ii-th symbol occurring
  • log⁡2\log_2 — logarithm base 2 (gives the result in bits; use natural log for nats)
  • ∑i\sum_i — sum over all possible symbols in the alphabet

A fair coin flip has maximum entropy: both outcomes equally likely, maximum surprise. A biased coin that lands heads 99% of the time has very low entropy — you're almost never surprised. The cross-entropy generalises this: instead of using the true distribution pp, you encode with a model distribution qq:

2
H(p,q)=−∑ipilog⁡2(qi)\quad H(p, q) = -\sum_{i} p_i \log_2(q_i)

Explanation: Cross-entropy measures how many bits you waste when you use model q to encode data that actually comes from distribution p — the further q is from p, the higher the cost. This is exactly the cross-entropy loss function used to train classification neural networks in PyTorch and TensorFlow. Minimising it means making your model's predicted distribution qq as close as possible to the true distribution pp. ```python import math def shannon_entropy(probabilities): """ Calculate Shannon entropy in bits. probabilities: list of floats that sum to 1.0 """ return -sum(p * math.log2(p) for p in probabilities if p > 0)

# A fair coin: maximum entropy fair_coin = [0.5, 0.5] print(f"Fair coin entropy: {shannon_entropy(fair_coin):.3f} bits")

# → Fair coin entropy: 1.000 bits

# A biased coin: low entropy biased_coin = [0.99, 0.01] print(f"Biased coin entropy: {shannon_entropy(biased_coin):.3f} bits")

# → Biased coin entropy: 0.081 bits

# A 6-sided fair die: higher entropy fair_die = [1/6] * 6 print(f"Fair die entropy: {shannon_entropy(fair_die):.3f} bits")

# → Fair die entropy: 2.585 bits ``` Shannon also defined channel capacity — the maximum rate at which information can be reliably transmitted through a noisy channel:

3
C=Blog⁡2 ⁣(1+SN)\quad C = B \log_2\!\left(1 + \frac{S}{N}\right)

Explanation: This is the Shannon–Hartley theorem; it says the maximum error-free data rate C through a channel equals its bandwidth B times a factor that grows with the signal-to-noise ratio S/N.

Symbols:

  • CC — channel capacity in bits per second
  • BB — bandwidth of the channel in Hz
  • S/NS/N — signal-to-noise ratio (dimensionless)

This formula is why your Wi-Fi gets slower in a noisy environment — the S/NS/N ratio drops, reducing CC. ```python import math def channel_capacity(bandwidth_hz, snr): """ Shannon-Hartley theorem. bandwidth_hz: channel bandwidth in Hertz snr: signal-to-noise ratio (linear, not dB) Returns capacity in bits per second. """ return bandwidth_hz * math.log2(1 + snr)

# Typical Wi-Fi: 20 MHz bandwidth

# Good signal: SNR ≈ 100 (20 dB)

# Noisy signal: SNR ≈ 3 (5 dB) bw = 20e6 # 20 MHz print(f"Good signal capacity: {channel_capacity(bw, 100)/1e6:.1f} Mbps") print(f"Noisy signal capacity: {channel_capacity(bw, 3)/1e6:.1f} Mbps")

# → Good signal capacity: 132.9 Mbps

# → Noisy signal capacity: 40.0 Mbps ```

researcher · Claude Elwood Shannon | 1916 – 2001 | Founded Information Theory

Shannon grew up in Gaylord, Michigan, tinkering with radios and building a telegraph from barbed wire to a friend's house half a mile away; he later earned degrees in electrical engineering and mathematics from MIT. His 1948 paper A Mathematical Theory of Communication, published in two parts in the Bell System Technical Journal, single-handedly created information theory — it defined entropy, channel capacity, and source coding theorems that remain the bedrock of every digital communications system today. A surprisingly playful character, Shannon was known for riding a unicycle through the hallways of Bell Labs while juggling, and he built a chess-playing machine called "Caissac" and a flame-throwing trumpet as personal side projects.

Figure
Shannon Communication System
Shannon's General Communication System (1948) Information Source e.g. your text message Transmitter / Encoder compress & encode signal Noisy Channel Wi-Fi, cable… Noise Source received Receiver / Decoder decode & decompress message Destina- tion e.g. you H(X) bits/symbol C = B log₂(1 + S/N)

Intuition

The Mental Model

Imagine you receive a text message from a friend. If the message says "the sun rose this morning," you learn almost nothing — you already knew that with near-certainty. But if the message says "I just won the lottery," your jaw drops: that's high-information content because it was very unlikely. Shannon's entropy is exactly that intuition, averaged over all the messages a source could send. Think of entropy as the "surprise budget" of a communication source. A weather forecast for the Sahara in July (always sunny) has near-zero entropy — no budget needed. A weather forecast for London (anything is possible) has high entropy — a big surprise budget is required. The entropy tells you the minimum number of yes/no questions you'd need to ask on average to identify which message was sent — which is also the minimum number of bits needed to encode it. For neural networks, cross-entropy loss works the same way: when the model is confidently wrong, cross-entropy is very high (big surprise). When the model is confidently right, cross-entropy is near zero. Training minimises the average surprise.

Historical Development

Origins · 1 minhow this was discovered
History
1838
Samuel Morse builds the electric telegraph and invents Morse code — an early, intuitive (non-mathematical) form of variable-length encoding that assigns shorter codes to more frequent letters.
1924
Harry Nyquist at Bell Labs publishes "Certain Factors Affecting Telegraph Speed," deriving the first formula relating channel bandwidth to transmission rate.
1928
Ralph Hartley publishes "Transmission of Information," introducing the logarithmic measure of information — a direct precursor to Shannon's entropy formula.
1936
Alan Turing's "On Computable Numbers" paper establishes the theoretical foundations of computation, laying groundwork for thinking about information processing in formal terms.
1943
Warren McCulloch and Walter Pitts publish their model of artificial neurons — the same year Shannon meets Turing at Bell Labs during war work, where they discuss mathematical theories of the brain.
1948
Claude Shannon publishes "A Mathematical Theory of Communication" in two parts in the Bell System Technical Journal — defining entropy, channel capacity, source coding theorem, and channel coding theorem in a single landmark paper.
1949
Shannon and Warren Weaver publish the book-length expansion The Mathematical Theory of Communication, making the ideas accessible to a wider scientific audience.
1951
Shannon publishes "Prediction and Entropy of Printed English," showing English text has about 1 bit per character of true entropy — far below its 8-bit ASCII encoding — anticipating modern compression by decades.
1965
Kolmogorov introduces algorithmic complexity (Kolmogorov complexity), connecting Shannon's probabilistic information theory to computational complexity and laying groundwork for modern data compression theory.
2006
Geoffrey Hinton's deep belief networks and subsequent deep learning renaissance bring Shannon's cross-entropy loss to the forefront of AI training — it remains the standard loss function for classification to this day.

Why It Matters

Real-World Impact
Neural Network Training (Cross-Entropy Loss)Every modern classification model — from BERT to ResNet to GPT — uses Shannon's cross-entropy as its training loss. PyTorch's `nn.CrossEntropyLoss` and TensorFlow's `CategoricalCrossentropy` are direct implementations of Equation [2] above; minimising them is mathematically equivalent to maximising the likelihood of the training data under the model.
Data Compression (ZIP, JPEG, MP3)Shannon's source coding theorem proves that no lossless compression scheme can compress below the entropy rate of the source. ZIP files use Huffman coding and LZ77, both entropy-coding schemes; JPEG uses discrete cosine transforms followed by Huffman coding of the coefficients — all descendants of Shannon's 1948 theorems.
Tokenisation and Language ModelsWhen GPT-4 or LLaMA reports "perplexity" during training, that is 2H(p,q)2^{H(p,q)} — cross-entropy exponentiated. A perplexity of 10 means the model is, on average, as confused as if it had to choose uniformly among 10 equally likely next tokens. Lower perplexity = better model.
Mutual Information in Feature SelectionML practitioners use mutual information I(X;Y)=H(X)−H(X∣Y)I(X; Y) = H(X) - H(X|Y) to select which input features are most informative about a target label. scikit-learn's `mutual_info_classif` implements this directly and is used in feature selection pipelines.
Variational Autoencoders (VAEs)The VAE training objective (ELBO) contains a KL-divergence term DKL(q∥p)D_{KL}(q \| p), which equals cross-entropy minus entropy — a direct Shannon quantity. Minimising it forces the latent space to be information-theoretically compact.
Error-Correcting Codes in StorageSSDs and satellite links use turbo codes and LDPC codes, designed using Shannon's channel coding theorem. Modern NVMe SSDs achieve code rates within a fraction of a percent of the Shannon limit.
Reinforcement Learning (Maximum Entropy RL)Algorithms like Soft Actor-Critic (SAC) add an entropy bonus αH(π)\alpha H(\pi) to the reward, explicitly encouraging exploration by maximising the entropy of the policy distribution — preventing premature convergence to suboptimal deterministic policies.

Prerequisites

What This Leads To

See Also

Alan Turing and the Foundations of Computation · Maximum Likelihood Estimation · Entropy Regularisation in Reinforcement Learning · Huffman Coding and Data Compression · Perplexity as a Language Model Metric

Where this leads