Shannon Entropy and Classical Information Measures
Information theory begins with a deceptively simple question: how much can a message be squeezed before something is lost? Claude Shannon's 1948 answer is that the irreducible content of a source emitting symbols with probabilities is captured by a single number, the entropy , measured in bits when the logarithm is base two. A symbol of probability carries surprisal bits — a certainty () surprises us not at all, a one-in-a-million event carries about twenty bits — and is simply the expected surprisal. A maximally uncertain source, uniform over outcomes, has ; a deterministic source has . What makes the entropy more than a convenient average is that it is forced. Shannon and later Khinchin showed it is the unique function, up to the choice of unit, obeying a short list of natural axioms — continuity in the probabilities, the rule that spreading probability over more equally likely outcomes always raises uncertainty, and a grouping rule under which a hierarchically generated choice decomposes additively. And it is operational: the source coding theorem promotes from an axiomatic curiosity to a hard physical limit, the fewest bits per symbol into which a long stream can be losslessly compressed, no fewer, guaranteed by the asymptotic equipartition property that concentrates almost all probability on roughly typical sequences. From this one number the whole algebra of classical information measures unfolds — joint entropy, conditional entropy, mutual information, and the relative entropy whose single inequality, , is the engine behind nearly every bound in the subject. These are exactly the quantities that lift into quantum information theory when distributions become density operators and becomes the von Neumann entropy, so understanding the classical layer first makes crisp which features are universal and which are quantum signatures.
- The Shannon entropy measures the average uncertainty, in bits, of a discrete random variable — the expected surprisal of its outcomes.
- It is the unique measure (up to a unit) obeying continuity, monotonicity under uniform spreading, and the grouping axiom — the Shannon–Khinchin characterization.
- Source coding: is the minimum average bits per symbol to losslessly compress an i.i.d. source, and the direct classical ancestor of Schumacher quantum data compression.
- Joint entropy, conditional entropy, mutual information , and relative entropy assemble into the chain rules and the data-processing inequality that govern all of information theory.
- Relative entropy (Gibbs' inequality) is the master nonnegativity from which subadditivity, , and data processing all follow.
- Every measure here has a quantum lift — , , — but the quantum versions add subtleties like negative conditional entropy.
- Key idea: the surprisal of an event of probability is bits, the Shannon entropy is its average, and it equals the optimal compression rate of an i.i.d. source; every other classical information measure is a linear combination of entropies whose inequalities reduce to the nonnegativity of relative entropy.
The surprisal of an event of probability is bits; the Shannon entropy is its average, , and it equals the optimal compression rate of an i.i.d. source. All other classical information measures are linear combinations of entropies, and their inequalities ultimately reduce to the nonnegativity of relative entropy.
Where this lives today
Shannon's bits are the working currency of the digital world and the launchpad of its quantum successor. Every general-purpose compressor — the entropy coders inside ZIP, PNG, JPEG, H.264, and modern neural codecs — is engineered to approach the source coding limit per symbol, and arithmetic and asymmetric-numeral-system coders get within fractions of a bit of it on real data. The noisy channel coding theorem, , is the target that turbo codes, LDPC codes, and polar codes were designed to reach, and 5G and deep-space links now operate within a fraction of a decibel of the Shannon limit. Relative entropy is the loss function at the heart of machine learning — training a classifier by cross-entropy is minimizing between the data and the model — and it supplies the error exponents of hypothesis testing through Stein's lemma. The frontier is the quantum lift: replacing distributions by density operators sends , , and , and the open problems there — the additivity of channel capacities, the exact rates for entanglement-assisted communication, the role of strong subadditivity in constraining many-body entanglement — are all posed in the language Shannon built, with the classical inequalities of this article as the constraints they must respect.
The physical picture
Think of entropy as the expected number of yes/no questions needed to pin down an outcome under the smartest questioning strategy. For a uniform distribution over eight symbols you always need questions; for a skewed source you can do better on average by asking about the likely symbols first — and the best any strategy can do is exactly questions per symbol, a limit that Huffman and arithmetic codes approach. The entropy is therefore not a description of a message but a property of the source that emits it: it is the average price, in bits, of resolving one draw. The first figure makes the shape of this price concrete for the simplest possible source, a single biased coin, where the whole story lives on one curve.
The measures that describe pairs of variables are best seen as areas. Draw the uncertainty of as one disc and of as another; where they overlap is the information the two share, and the mutual information is exactly that overlap. The joint entropy is the total area of the union, the conditional entropy is the crescent of that survives once is known, and the identity is just inclusion–exclusion for two sets. The second figure is that Venn diagram made quantitative — the picture is exact for classical variables and, as the article on quantum mutual information will show, only a heuristic once operators enter.
Underneath both figures sits the reason a single number can be a hard limit at all: the asymptotic equipartition property, the law of large numbers for information. Over a long run of independent draws the sequences split sharply into a typical set of about members, each occurring with probability near , plus an exponentially negligible remainder. Compression is then nothing more than handing each typical sequence an index — and there are only of them, so bits suffice. Relative entropy measures the cost of getting the source wrong: build a code tuned to a model while the data actually follow , and you overspend by exactly bits per symbol.
The core equations
The definition is an expectation of surprisal. Each outcome carries bits of surprise — larger for rarer events — and the entropy averages this over the source, so it is small when a few symbols dominate and large when probability is spread evenly.
where: — discrete random variable with alphabet ; — probability , with ; — surprisal (self-information) of outcome , in bits; — expected surprisal . Reading it: is the average number of bits an ideal code spends per symbol, and the convention (justified by ) lets zero-probability symbols drop out silently. The entropy is pinned between two extremes: it cannot be negative, and it cannot exceed the entropy of the uniform distribution on the same alphabet. Both bounds are sharp.
where: — the number of symbols carrying nonzero probability. The lower bound is attained by a deterministic source and the upper bound by the uniform one; the gap turns out to be itself a relative entropy, which is why it can never be negative. For a pair of variables the joint entropy is the entropy of the combined outcome, treating as one random variable over the product alphabet.
where: — joint probability . It measures the total uncertainty in learning both variables at once, and reduces to exactly when and are independent. Conditional entropy is the uncertainty in that remains after is revealed, averaged over what might be. Two equivalent forms — an average of conditional entropies, and a difference of joint and marginal — coincide by the product rule.
where: — entropy of the conditional law given a specific ; — conditional probability . Because it is a probability-weighted average of ordinary (nonnegative) entropies, the classical always — a fact that fails quantumly and signals entanglement when it does. Mutual information is the reduction in uncertainty about that knowing buys — symmetrically, the information the two share. It has three faces: a combination of entropies, a difference of a marginal and a conditional, and a divergence.
where: — shared information, equal to . It is symmetric, nonnegative, and vanishes precisely when and are independent; it is the classical prototype of the quantum mutual information . Relative entropy — the Kullback–Leibler divergence — is the master quantity. It is a directed, asymmetric measure of how distinguishable a true distribution is from a reference , and it is the penalty paid for modelling by .
where: — reference distribution; if for some ; the value is generally asymmetric, . Its nonnegativity (Gibbs' inequality, derived below) is the single fact from which the bounds on , the positivity of , subadditivity, and data processing all descend. Two structural identities close the toolkit. The chain rule decomposes the entropy of many variables into a telescoping sum of conditionals, and the data-processing inequality forbids any post-processing from manufacturing information.
where: — jointly distributed variables; — a Markov chain, meaning is conditionally independent of given . The chain rule is the additive backbone of every multivariate calculation; the data-processing inequality is the formal statement that you cannot learn more about by looking at a processed copy than by looking at itself.
The goal is to prove the one inequality that everything else in this article rests on: that the relative entropy is never negative, and equals zero only when and are the same distribution. This is the classical parent of Klein's inequality for density operators, and once it is in hand the bounds on entropy, the positivity of mutual information, subadditivity, and the data-processing inequality all follow by short algebra rather than fresh analysis. The whole proof is the elementary logarithm bound applied one symbol at a time.
Step 1. Convert bits to nats so the natural logarithm's calculus is available: , since . Why: the constant cannot change a sign, so proving in nats proves it in bits; and the bound we need is a fact about , not .
Step 2. Flip the ratio and apply (equality only at ) with :
Why: the tangent-line bound is the single piece of convexity that does all the work; summing it over the support of turns an entropy inequality into an arithmetic one.
Step 3. Collapse the right-hand side using normalization, and :
Hence , i.e. . Equality forces everywhere on the support, so . Why: the two probabilities each sum to one, so the linearized bound telescopes to exactly zero — the inequality is saturated only when the tangent touches, which is the equality condition of Step 2.
Go deeper · Derivation B · 1 minSubadditivity, positivity of mutual information, and data processing
The aim is to show that three of the most-used inequalities in the subject — that joint entropy cannot exceed the sum of the marginals, that mutual information is nonnegative, and that processing a variable cannot increase what it tells you — are all the same statement wearing different clothes, each a direct corollary of Gibbs' inequality proved above. The trick throughout is to recognize a mutual information as a relative entropy between a true joint law and a factorized reference, so that does the entire job.
Step 1. Rewrite mutual information as a divergence: , with equality iff . Why: the product of marginals is the "if they were independent" reference, and Gibbs measures exactly how far the true joint law sits from it — so positivity of is positivity of .
Step 2. Translate back to entropies. Since , we get subadditivity directly:
with equality iff and are independent. Why: subadditivity is just rearranged — combining two sources never needs more bits than describing them separately, and needs strictly fewer when they are correlated.
Step 3. For a Markov chain , the chain rule gives . The Markov property makes , and the conditional mutual information (Gibbs again, conditioned on each ), so . Why: every conditional mutual information is an average of ordinary divergences and so nonnegative; dropping the nonnegative leaves the data-processing inequality . *Classical subadditivity is elementary — a direct corollary of — whereas the quantum strong subadditivity of Lieb and Ruskai is a far deeper theorem.*
Go deeper · Derivation C · 1 minSource coding — the typical set and the compression rate H(X)
The goal is to turn the entropy from an axiomatic average into an operational limit by proving the asymptotic equipartition property: for a long i.i.d. source the sequences that actually occur are almost all "typical", they number at most , and each carries nearly the same probability. Indexing this typical set is the whole of lossless compression, and it pins the achievable rate at bits per symbol — the classical result that Schumacher later lifted to qubits.
Step 1. Define the typical set by the empirical log-probability:
By the weak law of large numbers applied to , this sample mean converges in probability to , so . Why: surprisal is itself a random variable with mean ; the AEP is nothing but the law of large numbers for that variable, forcing almost all probability into the typical band.
Step 2. Bound the size using total probability. Each typical sequence has , and the typical set's probability cannot exceed one:
Why: if every member weighs at least and they collectively weigh at most one, there can be at most of them — a counting argument, nothing more.
Step 3. Read off the count and the rate:
A fixed-length code assigning a distinct index to each typical sequence therefore needs at most bits, i.e. bits per symbol, while the exponentially rare atypical sequences contribute negligibly to the average. Why: compression is just labelling the sequences that occur, and there are only about of them — the converse (that no code beats ) uses the matching lower bound on the typical set's size.
Limiting cases
Special distributions expose the meaning and the extreme values of the entropy, and the divergence between them.
| Case | Result | Meaning |
|---|---|---|
| Deterministic source | No uncertainty, no information; the minimum, using by continuity. | |
| Uniform over outcomes | Maximum entropy for a -valued variable; equals the bits needed to label items. | |
| Fair binary source | bit | The peak of the binary entropy curve; one clean bit of uncertainty per coin. |
| Independent variables | Entropy is additive over independent parts; mutual information detects all correlation. | |
| (perfect model) | The divergence vanishes only when the model matches the source exactly. |
Worked examples
1 · A dyadic source, its entropy, and an optimal code (fully worked)
A source emits four symbols with probabilities . Find its entropy, exhibit a code that meets the entropy bound exactly, and compute the relative-entropy penalty of instead coding it as if it were uniform.
Step 1. Entropy from the definition. Each surprisal is : symbol carries bit, carries bits, and each carry bits. Averaging,
Because every probability is a power of two (a dyadic source), the surprisals are whole numbers of bits.
Step 2. A code that hits the bound. Assign codewords of length equal to each surprisal — , , , (a Huffman code). This prefix-free code has average length bits per symbol, equal to with no gap. Dyadic sources are exactly the case where an integer-length code achieves the entropy; for general sources Huffman coding lands within one bit and arithmetic coding closes the remainder asymptotically.
Step 3. The penalty for the wrong model. Suppose you instead used a flat code tuned to the uniform distribution — two bits for every symbol. The overspend per symbol is the relative entropy:
Consistency check: the flat code costs exactly bits/symbol, and indeed bits. This also confirms the identity , since . Answers: bits, an optimal code averages bits/symbol, and the uniform-model penalty is bit/symbol.
2 · Mutual information through a noisy channel
A uniformly random input bit passes through a binary symmetric channel that flips it with probability , producing . How much does observing tell you about ?
Step 1. By symmetry the output is also uniform, so bit. Given the input, the only remaining randomness is the flip, so .
Step 2. Evaluate the binary entropy of the noise: (the same value as by symmetry).
Step 3. Mutual information is the output uncertainty minus the noise: . Since the uniform input maximizes for this channel, this is also the channel capacity bit per use — the most reliable information a -flip channel can carry. Answer: each use of the channel conveys bit, and this equals its capacity.
Physics of the portrait
The classical information measures are the work of one decisive paper and a small circle around it — a wartime cryptanalyst who saw that "information" could be measured in bits, that a source has an irreducible rate, and that noise sets a hard but achievable ceiling on communication.
Origins · 1 minClaude Shannon and how this was discovered
Claude Elwood Shannon was an American mathematician and electrical engineer whose 1948 paper A Mathematical Theory of Communication, published in the Bell System Technical Journal, created information theory nearly complete in a single stroke. As a graduate student at MIT he had already, in his 1937 master's thesis, shown that Boolean algebra could describe switching circuits — arguably the most consequential master's thesis ever written, and the logical foundation of digital design. Turning to communication during and after his wartime cryptography work at Bell Labs (where he interacted with Alan Turing), he isolated the quantity , borrowed the name "entropy" on von Neumann's advice for its formal identity with the Boltzmann–Gibbs expression, and proved the two theorems that anchor the field: the source coding theorem, fixing the compression limit at , and the noisy channel coding theorem, fixing the reliable communication rate at the capacity . He introduced mutual information, conditional entropy, the typical-set argument, and the very notion of the "bit" as the unit of information. Famously playful — he built a juggling unicycle, a mechanical mouse that solved mazes, and a machine whose only function was to switch itself off — Shannon gave the emerging digital and, later, quantum information sciences their common language: every quantum entropy, capacity, and coding theorem is a deliberate lift of a structure he first drew for classical bits.
Going further
Texts. Nielsen and Chuang, Quantum Computation and Quantum Information, Ch. 11–12 · Cover and Thomas, Elements of Information Theory, Ch. 2–3 · Wilde, Quantum Information Theory, Ch. 10 · Preskill, Lecture Notes on Quantum Computation, Ch. 10 · Watrous, The Theory of Quantum Information, Ch. 5 · Shannon, A Mathematical Theory of Communication, Bell Syst. Tech. J. (1948) · Mermin, Quantum Computer Science, Ch. 5. Key numerical anchors: bit and bit by direct computation; the dyadic source has bits with a Huffman code of average length , and bit matching ; the binary symmetric channel with has bit; the Gibbs inequality rests on and the AEP set-size bound is .
Prerequisites. Probability theory (discrete random variables, joint and conditional distributions) · Convexity and Jensen's inequality · Logarithms and basic asymptotics. Leads to. Von Neumann Entropy · Quantum Relative Entropy · Quantum Conditional Entropy and Mutual Information · Schumacher Data Compression · Holevo Bound · Data-Processing Inequality.
Ask the tutor: Ask me to walk you through why is the exact compression limit — or to show, step by step, how every inequality here falls out of the single fact that relative entropy is nonnegative.
Why the logarithm — why is information measured on a log scale?
Because information should add for independent sources. If a source has equally likely messages and a second independent source has , the combined source has joint messages, yet intuitively it carries the sum of the two informations, not the product. The only continuous function turning products into sums is the logarithm, so forces the log scale. Choosing base two makes the unit the bit — the information in one fair coin flip. Base gives nats and base ten gives dits; they differ only by a constant factor, since . Shannon's grouping axiom is the precise statement that pins the logarithm down uniquely.
What is the difference between surprisal and entropy?
Surprisal is a property of a single outcome; entropy is a property of the whole source. The surprisal tells you how many bits of "surprise" the specific outcome delivers — a near-certain event surprises you barely at all, a rare event a great deal. The entropy is the expected surprisal, averaging over which outcome the source will actually produce. So a single low-probability symbol can carry twenty bits of surprisal, yet contribute little to the entropy if it almost never appears. When people say " has three bits of entropy" they mean the source averages three bits of surprise per draw, which is also the average codeword length of an ideal compressor.
Why is relative entropy asymmetric, and which order should I use?
Because the two arguments play different roles: is the expected log-likelihood ratio under the true distribution , weighting each term by . Swapping to reweights by and asks a different question, so the two numbers generally differ — and one can be finite while the other is infinite if their supports disagree. The rule of thumb: put the truth (or the data distribution) first and the model second, , because that is the quantity equal to the extra bits per symbol you pay for using the model — and it is the "forward KL" that maximum-likelihood training minimizes. The reverse order appears in variational inference for its own reasons, but "truth first" is the coding-theoretic default.
How is Shannon's entropy related to the thermodynamic entropy of physics?
They are the same functional, , and the connection is not a coincidence — von Neumann reportedly suggested the name to Shannon precisely because the formula matched Boltzmann's and Gibbs'. Thermodynamic entropy (in units where Boltzmann's constant and the log is natural) is the Shannon entropy of the probability distribution over a system's microstates, so it counts the bits of missing information about which microstate the system occupies. Landauer's principle makes the link physical: erasing one bit of information necessarily dissipates at least of heat. The main difference is domain, not form — thermodynamics fixes the distribution by maximum entropy under energy constraints (giving the Boltzmann distribution), whereas information theory takes the distribution as given.
Can mutual information ever exceed the entropy of one of its variables?
No. Since and the classical conditional entropy , mutual information is bounded by , and symmetrically , so . The overlap in the information diagram can never be larger than either disc. Equality happens exactly when determines (then ), meaning tells you everything about . This bound is one of the places the classical picture is cleaner than the quantum one: the quantum mutual information can reach for entangled states, twice the classical ceiling, which is the information-theoretic fingerprint of superdense coding.
Does the source coding theorem apply to real files, which are not i.i.d.?
The clean rate assumes independent, identically distributed symbols, and real data — text, images, audio — are strongly correlated, so a symbol-by-symbol entropy overstates their true information content. The theorem still governs them through the entropy rate , which accounts for all the inter-symbol correlations and is the correct compression limit for a stationary source. Practical compressors exploit exactly this: they model context (predicting each symbol from its predecessors) to drive the effective per-symbol entropy far below the naive marginal value. This is why an English text file compresses to roughly one bit per character rather than the four-plus bits its letter frequencies alone would suggest — the redundancy lives in the correlations.