Applied and computational mathematics
Information theory
Quantifies information and communication limits using entropy, founded by Claude Shannon.
IntuitionGuessing games and how much a message really tells you
Imagine someone flips a coin and tells you the result. If the coin is fair, you learn something genuinely surprising each time — heads and tails are equally likely, so you could not have guessed the outcome in advance. If the coin almost always lands heads, hearing "heads" tells you almost nothing (you expected it), while hearing the rare "tails" is a small shock carrying much more information. Information theory turns this everyday intuition — rare, surprising outcomes carry more information than expected, predictable ones — into an exact number.
SchoolBits, surprise, and the entropy formula
Definition: Shannon entropy
For a random variable taking value with probability (for ), the Shannon entropy is the average number of bits of surprise per outcome: . The term is the "surprise" of outcome — large when is small (rare, surprising) and when (certain, no surprise) — and averages this surprise, weighted by how often each outcome actually occurs.
Here is the number of possible outcomes, is the probability of outcome (with ), and the logarithm base means is measured in bits. The most important special case is a coin with two outcomes, probability and : , called the binary entropy function.
| Distribution | Entropy |
|---|---|
| Fair coin, | bit (maximal for 2 outcomes) |
| Biased coin, | bits |
| Uniform over outcomes | bits () |
| Deterministic, | bits (no surprise at all) |
UndergraduateGibbs' inequality, optimal codes, and channel capacity
Given two probability distributions and on the same outcomes, the Kullback–Leibler divergence measures how much is "wasted" by assuming outcomes follow when they really follow : . This quantity underlies why entropy behaves the way it does, and why no code can beat the entropy bound — both are consequences of the following inequality.
For any two probability distributions and on the same outcomes (all ), , with equality if and only if .
Why is it true?
The logarithm is concave, so "on average" it lies below its tangent line. Gibbs' inequality is exactly Jensen's inequality applied to the concave function , weighted by : it says that replacing each ratio by its -weighted average (which equals ) inside the logarithm can only increase the sum, forcing the divergence to be nonnegative.
Proof
Start from the elementary inequality for all , with equality only at (this follows since has , , which is positive for and negative for , so has a unique maximum at ). Dividing by gives .
Apply this with for each : . Multiply both sides by (which does not flip the inequality) and sum over : , since both and are probability distributions summing to .
The left side is exactly (note the sign flip from versus inside the log), so this proves .
Equality throughout requires equality in for every with , which happens only when for every such , i.e. .
To store or transmit outcomes of efficiently, we assign each outcome a binary codeword of length , chosen so no codeword is a prefix of another (a prefix code), which lets a receiver decode a stream of codewords instantly without ambiguity. Not every list of lengths is achievable: the lengths of a prefix code must satisfy the Kraft inequality, .
For a source with entropy , every prefix code has average codeword length satisfying , and there exists a prefix code with .
Why is it true?
The lower bound says entropy is a hard floor: no lossless prefix code can, on average, beat bits per symbol, because doing better would require the code-induced distribution to differ from 's true distribution in a way Gibbs' inequality forbids. The upper bound says this floor is nearly achievable: rounding each ideal length up to an integer wastes less than one bit on average.
Proof
For the lower bound, let be the lengths of any prefix code, so . Define where , so is a probability distribution. By Gibbs' inequality, . Since , , so , which rearranges to .
For the upper bound (achievability), choose for each (round the ideal length up to the nearest integer). These lengths satisfy Kraft's inequality since , so ; by the Kraft–McMillan construction such lengths can always be realized as an actual prefix code (build the code by assigning binary strings level by level in a binary tree).
By definition of ceiling, . Multiplying by and summing over gives .
Combining both parts, this construction achieves .
Now suppose messages are sent over a noisy channel: the receiver sees when was sent, and noise can flip symbols. The mutual information measures how many bits about survive the noise, on average — it is the entropy of minus the leftover uncertainty after seeing . The channel capacity is the largest mutual information achievable by choosing the best input distribution .
The simplest noisy channel is the binary symmetric channel (BSC): each transmitted bit is flipped independently with crossover probability . Its capacity works out to , using the same binary entropy function from before — a clean bridge between the source-coding and channel-coding halves of the theory.
For a discrete memoryless channel with capacity , reliable communication (error probability ) is possible at any transmission rate bits per channel use with , using sufficiently long block codes; conversely, no coding scheme can achieve at any rate .
Why is it true?
Capacity is not merely a convenient formula — it is a genuine wall. Below it, spreading each message over a long enough block lets random-looking codewords stay distinguishable despite noise, so errors can be driven to zero; above it, the channel destroys information faster than any code can protect it, no matter how clever the code.
Proof
**Converse ().** Fano's inequality bounds the receiver's remaining uncertainty about the message given the noisy output: , where is the number of possible messages. Meanwhile, the data-processing structure of the channel forces for every use, so over a block of channel uses the total information the receiver can extract is at most bits. If the true rate is bits per use, the message carries bits of entropy but the channel supplies only about bits about it; Fano's inequality then forces to stay bounded away from as grows, since the leftover uncertainty cannot be made to vanish.
**Achievability sketch ().** Fix an input distribution achieving the capacity and generate a codebook of codewords of length independently at random from . To decode, the receiver looks for the unique codeword that is jointly typical with the received sequence (i.e. behaves, in its statistical patterns, like a genuine input–output pair). Because , the number of candidate codewords () is far smaller than the number of statistically distinguishable channel outputs (), so as the chance that some other, unsent codeword accidentally looks jointly typical with the received sequence shrinks to , and so does the decoding error probability, averaged over the random choice of codebook — hence at least one codebook must achieve arbitrarily small .
| Channel | Capacity |
|---|---|
| Noiseless binary channel | bit per use |
| Binary symmetric channel, crossover | |
| Binary erasure channel, erasure probability | |
| Binary symmetric channel, (fully noisy) | (no information gets through) |
UndergraduateReal-World Applications and Worked Examples
Every digital technology that compresses or transmits data leans on these two theorems. Source coding underlies ZIP, JPEG, and MP3 compression (get close to the entropy of the data); channel coding underlies Wi-Fi, deep-space communication, and QR codes (add just enough redundancy to survive noise, but no more than demands).
Example: Building a code that meets the entropy bound exactly
A sensor reports one of four states with probabilities . Find , propose prefix-code lengths satisfying Kraft's inequality with equality, and check whether the resulting average length matches the entropy bound.
Solution
First compute the entropy directly from the formula: each term is , giving , , and two terms each. Summing: bits.
Because every probability here is a power of two (), the ideal codeword lengths are already integers: . Check Kraft's inequality: , satisfied with equality, so a prefix code with exactly these lengths exists (for instance ).
The average codeword length is bits.
So exactly, meeting the lower bound of the noiseless source coding theorem with equality — this happens precisely because the distribution is dyadic (every probability a power of two), so no bit is ever wasted rounding lengths to integers.
Example: How much redundancy does a noisy memory chip need?
A flash-memory cell has a raw bit-flip probability per stored bit, modeled as a binary symmetric channel. Compute the channel capacity , and interpret what it means for how much of the raw storage must be spent on error-correcting redundancy to read data back reliably.
Solution
First compute the binary entropy at : and , so bits.
The capacity is then bits per stored bit.
This means that, in principle, only about half of the raw storage capacity can carry reliable information once error-correcting redundancy is added — a rate close to bits per raw cell is the best any error-correcting code can achieve while still driving the error probability toward zero on this channel; codes attempting a higher rate cannot be made reliable, no matter how sophisticated their design.
In practice, real flash-memory controllers use error-correcting codes such as BCH or LDPC codes at rates chosen safely below this -bit theoretical ceiling, trading some of that margin for practical decoding complexity and finite block length.
A source has three equally likely outcomes, . What is ?
According to Gibbs' inequality, what is the smallest possible value of for two probability distributions ?
For a source with entropy , which statement about the average length of an optimal prefix code is guaranteed by Shannon's noiseless source coding theorem?
A binary symmetric channel has crossover probability (each bit is flipped with probability exactly one half). What is its capacity ?
References
- Claude E. Shannon (1948). A Mathematical Theory of Communication
- Thomas M. Cover, Joy A. Thomas (2006). Elements of Information Theory
- David J. C. MacKay (2003). Information Theory, Inference, and Learning Algorithms
- Erdal Arıkan (2009). Channel Polarization: A Method for Constructing Capacity-Achieving Codes for Symmetric Binary-Input Memoryless Channels · arXiv:0807.3917