The Asymptotic Equipartition Property
The information-theoretic law of large numbers, the typical set, the source code it yields, and its optimality among high-probability sets
Motivation: from one keystroke to a whole tape
So far every quantity we built (entropy, relative entropy, mutual information) is an average per keystroke. But a telecom engineer never sells a single keystroke. They sell a tape: a message of symbols punched out by an operator whose language habits are the pmf .
This raises an engineering question that the per-symbol averages cannot answer on their own. The operator can, in principle, type any of the possible tapes. If we must reserve a codebook slot for every one of them, the cost of the system is bits regardless of how skewed the language is, and all the structure we measured with bought us nothing.
IntuitionThe question we actually want answered
Out of the astronomically many tapes the machine could print, how many does it realistically print? If that realistic subset is far smaller than , an engineer only needs to build a codebook for the subset, and can dismiss everything else as an event too rare to pay for.
The Asymptotic Equipartition Property (AEP) is the answer, and it is the information-theoretic analogue of the law of large numbers.
| Law of large numbers | Asymptotic Equipartition Property | |
|---|---|---|
| Object averaged | The values themselves, | The surprise of the values, |
| Converges to | ||
| Physical reading | The average voltage of a long tape settles down | The average surprise of a long tape settles down |
Because settles at , the probability of whatever tape we actually observe settles at — the same value for essentially every tape we are ever likely to see.
IntuitionThe one-line summary
“Almost all events are almost equally surprising.” Formally, if are i.i.d. , then
ConventionTape notation
We write as shorthand for a sequence , and for the corresponding random tape. So is the probability the operator punches out that exact tape, and is the set of all tapes of length .
Intuition check: are all tapes equally likely?
A naive first guess is that the AEP is trivially true because every tape is equally likely anyway. It is not, and seeing why sharpens what the theorem is actually claiming.
Let the operator have a two-key machine, , with and . Since keystrokes are i.i.d., the probability of a specific tape is the product of the per-key probabilities:
ExampleA concrete tape
The tape has probability . A tape of six zeroes has probability . These are wildly different numbers whenever , so it is plainly not true that all tapes of length are equally probable.
So the AEP is not saying that the sample space is uniform. It is saying something weaker but far more useful: although the tapes have very different probabilities, the tapes that actually get printed almost all share roughly the same probability . In this binary example that is just the statement that the number of s on a printed tape is close to with high probability, and every tape with about ones carries about the same probability.
RemarkThe self-referential flavour
We are asking for the probability of the outcome , where the outcome is itself drawn according to that same distribution. This is insidiously self-referential, but perfectly well defined: is a random variable (a function of the ), and we are studying its distribution.
Convergence of random variables
The AEP is a statement about a random variable converging, so we need to fix which mode of convergence we mean.
DefinitionConvergence of random variables
Given a sequence of random variables , we say the sequence converges to a random variable :
- In probability if for every , .
- In mean square if .
- With probability 1 (also called almost surely) if .
IntuitionWhich one the AEP uses
Convergence in probability is the weakest of the three and is all we need. Physically it says: pick any tolerance you like on the average surprise per keystroke; as the tape gets longer, the fraction of tapes whose average surprise misses by more than shrinks to zero. It does not claim that a single infinitely long tape never has a bad stretch — only that a bad stretch at the moment you look becomes vanishingly unlikely.
The AEP theorem
TheoremAsymptotic Equipartition Property
If are i.i.d. , then
IntuitionPhysical meaning
Read the left side as a measurement taken off the printed tape: take the whole tape, compute its surprise , and divide by the number of keystrokes to get the sample entropy — the average bits of surprise per key actually delivered by this particular tape. Read as the blueprint property of the operator’s language, computed from the pmf alone with no tape in hand. The theorem says the measurement converges to the blueprint. Equivalently, since rearranges to , the tape you are holding is overwhelmingly likely to be one with probability about .
ProofReduce the joint surprise to a sample mean, then apply the weak law
Step 1: Independence survives the logarithm. Functions of independent random variables are themselves independent random variables. The are i.i.d., and is a fixed function applied to each one separately, so the random variables are also i.i.d. This is the step that licenses everything after it.
Step 2: The joint surprise is a sum, because the keystrokes are independent. Independence gives , and the logarithm turns that product into a sum — the same additivity that forced to be a logarithm in the first place (see [[entropy-mutual-information#The three conditions we need on |the three conditions on ]]):
The left side is the surprise of one enormous composite event; the right side is an ordinary sample mean of i.i.d. terms. The whole theorem is this rewriting.
Step 3: Apply the weak law of large numbers. A sample mean of i.i.d. terms converges in probability to the expectation of a single term:
Step 4: Recognize the expectation. By definition . Chaining Steps 2–4:
∎
The typical set
The AEP says the sample entropy of a printed tape concentrates on . That lets us physically partition the space of all possible tapes into two piles: the tapes whose sample entropy came out close to , and everything else.
flowchart LR S["All tapes: alphabet^n, count = |X|^n"] --> T["Typical set: sample entropy within epsilon of H"] S --> N["Nontypical set: everything else"] T --> TP["Probability nearly 1, count about 2^(nH)"] N --> NP["Probability nearly 0, count can be huge"]
DefinitionThe typical set
The typical set with respect to is the set of sequences with the property
| Component | Detail |
|---|---|
| Signature | — a set of tapes, not a number. |
| Parameters | , the tape length; , the tolerance we allow on the per-keystroke surprise. |
| Membership test | Compute the tape’s probability and check it lands in the band . Taking of all three parts turns this into the equivalent test . |
IntuitionWhat membership physically means
A tape is typical if it “sounds like the language.” Its letter frequencies came out close enough to the operator’s blueprint that its total surprise per key lands within of . It is not a statement about the content of the message — only about whether its statistics look ordinary for this source.
WarningThe most probable tape is usually not typical
Take a binary operator with . The single most likely tape of length is the all-ones tape, with probability — larger than any other individual tape. But its sample entropy is bits, while bits. It misses the band entirely and is atypical. “Typical” means representative of the source’s statistics, not most likely as an individual outcome: the typical tapes here are the ones whose proportion of s is close to , and the typical set wins on total probability not because its members are individually special, but because there are so enormously many of them. We return to this exact example in .
Properties of the typical set
TheoremProperties of
- If , then
- for sufficiently large.
- , where denotes the number of elements in the set .
- for sufficiently large.
IntuitionThe three physical facts, in order
Taken together, these say that the typical set has probability nearly 1 (property 2 — so an engineer who only handles typical tapes is almost never caught out), all its elements are nearly equiprobable (property 1 — so a fixed-length index wastes nothing, since no member deserves a shorter codeword than another), and it contains about elements (properties 3 and 4 — so indexing it takes about bits rather than ).
ProofProperty 1 — immediate from the definition
Start from the membership condition:
Take of all three parts (monotone, so inequalities are preserved):
Multiply through by , which is negative and therefore flips both inequalities:
So the “probability band” definition and the “sample entropy within ” description are literally the same condition, just written on different scales.
∎
ProofProperty 2 — the typical set captures nearly all the probability
This is exactly the AEP restated as a probability.
Step 1: Write the AEP in its - form. Theorem (AEP) says in probability. By the definition of convergence in probability, for any there exists an such that for all :
Step 2: Recognize the event. By Property 1, the event inside that probability — sample entropy within of — is the event . So the displayed line already reads .
Step 3: Set . The AEP holds for every , so we are free to choose , giving for sufficiently large. This identification is purely a notational convenience that keeps one symbol instead of two in everything that follows.
∎
ProofProperty 3 — upper bound on the size, from total probability
The argument is: each typical tape carries at least a known minimum probability, and all of them together cannot carry more than the total probability 1, so there cannot be too many of them.
Step 1: Start from the total probability of the whole tape space.
Step 2: Discard the atypical tapes. Restricting a sum of non-negative terms to a subset can only shrink it:
Step 3: Replace each term by its floor. By the membership definition, every typical tape has :
Step 4: Collapse the sum into a count. Every summand is now the same constant, so the sum is just that constant times the number of terms:
Step 5: Rearrange.
∎
ProofProperty 4 — lower bound on the size, from Property 2
Symmetric argument: the typical set carries nearly all the probability, but each of its members carries at most a known maximum, so there must be many of them.
Step 1: Start from Property 2. For sufficiently large,
Step 2: Replace each term by its ceiling. By the membership definition, every typical tape has :
Step 3: Collapse the sum into a count.
Step 4: Rearrange.
∎
RemarkWhy the two size bounds are proved in opposite directions
Property 3 needs a floor on each member’s probability (to stop the count running away), and property 4 needs a ceiling (to force the count up). The typical set’s defining band supplies exactly one of each, which is the whole reason the definition is a two-sided band rather than a single threshold.
Consequence: data compression
The problem. We now have a set of about tapes that soaks up nearly all the probability. But a set is not yet a product. The telecom engineer needs an actual code: a concrete mapping from every tape the machine might print to a binary string they can push down the wire. Two hard constraints:
- It must be one-to-one, so the receiver can invert it. We cannot simply refuse to encode the atypical tapes — rare is not impossible, and a code that silently fails on them is not a code.
- It must be cheap on average, since the telecom is charged per pulse actually sent, not per codeword slot reserved.
The tension is that these pull in opposite directions: covering every tape is what forces the cost in the first place. The resolution is to cover everything but charge differently for the two piles.
The two-part code
Order the elements within each pile by some fixed convention (lexicographic, say), and represent a tape by its index within its own pile, prefixed by a flag bit saying which pile it came from.
| Pile | Size | Index cost | Flag | Total length |
|---|---|---|---|---|
| Typical | bits | 0 | bits | |
| Atypical | bits | 1 | bits |
NoteWhere the two extra bits come from
One bit is the flag. The other is a ceiling: indexing items needs bits, and need not be an integer, so safely covers it. Same for the atypical pile.
IntuitionWhat the flag bit is physically doing
The initial bit is a length flag: it tells the receiver, before they have decoded anything, which of the two codeword lengths to read off the wire. That is what makes the scheme one-to-one and easily decodable despite the two piles having different codeword lengths.
RemarkWe are being deliberately wasteful, and it doesn’t matter
Notice that we indexed the atypical set by brute-force enumeration over all of , ignoring the fact that is strictly smaller than . We are paying full price for a pile we could have indexed more cleverly. Surprisingly, this crude treatment is still good enough to yield an efficient description — because the pile it wastes bits on has probability under , so the waste is multiplied by almost nothing.
Expected codeword length
Let be the length of the codeword assigned to tape . Take large enough that .
TheoremSource coding via the typical set
Let be i.i.d. and let . Then there exists a code mapping sequences of length into binary strings such that the mapping is one-to-one (and therefore invertible) and
for sufficiently large. That is: we can represent tapes using about bits on average.
ProofSplit the expectation by pile, bound each pile’s length, then bound each pile’s probability
Step 1: Write the expectation. By definition of expected value over all tapes:
Step 2: Split the sum along the partition. Every tape is in exactly one pile, so the sum splits cleanly with no double counting:
Step 3: Replace each length by its worst case. Within a pile, every codeword obeys the length bound from the construction table, so substituting the maximum can only increase the sum:
Step 4: Collapse each sum into a probability. The length factors are now constants within each pile and pull out, leaving bare sums of over each pile — which are by definition the piles’ probabilities:
Step 5: Bound the two probabilities — this is the step that does the work. For the typical term use the trivial bound (we are happy to pay full price on the cheap pile). For the atypical term use Property 2, (the expensive pile is charged at a rate of ):
Step 6: Collect into a single . Factor out :
Step 7: Check can be made arbitrarily small. The order matters. First choose small enough to crush — note this is possible because is a fixed constant of the alphabet, not something growing with . Then, with fixed, choose large enough to crush the term. Dividing through by gives the theorem.
∎
IntuitionWhat this buys the telecom company
A naive engineer reserves a codeword slot for all tapes and pays bits per message no matter what. This scheme pays about bits per message instead, and the gap is precisely the structure in the operator’s language — the same gap measured per-symbol by the maximum entropy bound. Nothing was thrown away to get it: the code is still one-to-one on every tape the machine can print.
High-probability sets and the typical set
The problem. From its definition, is clearly a fairly small set that contains most of the probability. But nothing in the definition says it is the smallest such set. Perhaps a cleverer engineer, picking tapes by hand rather than by the sample-entropy band, could find a much smaller set that still captures nearly all the probability — and then index it with far fewer than bits, beating the code we just built.
We settle this by defining the best possible competitor and showing it is no better, to first order in the exponent.
DefinitionSmallest high-probability set
For each , let be the smallest set with
IntuitionHow is built, and why it differs from
To make a high-probability set as small as possible you take the most probable tapes first and keep going until you have accumulated of the probability. So is a greedy top-of-the-list set, whereas is a band set. They are built by genuinely different rules, and they are not the same set — contains the single most probable tapes, which as we saw can be atypical.
TheoremSize of the smallest high-probability set
Let be i.i.d. . For and any , if , then
for sufficiently large.
NoteProof status
Cover & Thomas outline this proof in Problem 3.3.11 rather than giving it in the text. The argument sketch is: any set with probability above must have a significant intersection with (since itself carries nearly all the probability, and prevents from dodging it), and every tape in that intersection carries probability at most — so covering that much probability with such small pieces forces at least about pieces.
So must have at least elements, to first order in the exponent — while has elements by properties 3 and 4. The typical set is therefore about the same size as the smallest high-probability set, and no clever hand-picking beats it.
Equality to first order in the exponent
The phrase “to first order in the exponent” is doing real work above, so it gets its own notation.
DefinitionFirst-order exponential equality
The notation means
IntuitionWhat deliberately ignores
This says and agree in the exponent, not in the number. Two sets of sizes and satisfy , because dividing the log by kills any polynomial factor. For an engineer this is exactly the right resolution: what they pay is bits, so a polynomial factor costs a vanishing number of bits per symbol.
With this notation, the results of the whole note collapse to one line. If and , then
Illustration: where the two sets actually differ
Take a Bernoulli sequence with parameter , i.e. a binary operator who types with probability .
| Rule | Tapes whose proportion of s is close to | The most probable tapes, taken greedily until probability is covered |
| Contains all-ones tape? | No — its sample entropy is bits, far from | Yes — it is the single most likely tape of all |
| Contains the -ones tapes? | Yes, by construction | Yes — forced by the theorem |
| Size |
IntuitionThe reconciliation
The two sets are not equal — contains the all-ones tape and does not. But both are forced to contain the bulk of the tapes with about ones, and that bulk is what determines the size. The disagreement is over a handful of exceptional tapes that carry negligible total probability and negligible count, so the two sets are almost equal in size even though neither contains the other.
RemarkWhat is still open after all this
We have shown the typical set yields a code costing about bits per symbol, and that no smaller high-probability set exists to beat it. We have not proved a converse for arbitrary codes (that no one-to-one scheme whatsoever can average below ), and everything here assumed the source is i.i.d. — real operators have grammar, so their keystrokes are dependent, and extending the AEP to such sources needs the entropy rate of a stochastic process.
Quick reference
| Object | Statement | Reads as |
|---|---|---|
| AEP | in probability | Sample entropy of a long tape converges to the source’s blueprint entropy. |
| Typical set | Tapes whose statistics look ordinary for this source. | |
| Probability | The typical pile is almost everything that happens. | |
| Size (upper) | There are not many realistic tapes. | |
| Size (lower) | But there are not too few either — the count really is . | |
| Source code | A one-to-one code averaging about bits per tape exists. | |
| Optimality | No smaller high-probability set beats the typical set in the exponent. |
Constants to keep to hand:
- Typical codeword length: bits (index flag ceiling).
- Atypical codeword length: bits.
- Slack in the source coding theorem: — shrink first, then grow .
References
- [[lit/cover2006-elements|Cover & Thomas, Elements of Information Theory]] — Chapter 3