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

· 24 min read · 4,763 words

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 nn symbols X1,X2,,XnX_1, X_2, \ldots, X_n punched out by an operator whose language habits are the pmf p(x)p(x).

This raises an engineering question that the per-symbol averages cannot answer on their own. The operator can, in principle, type any of the Xn\lvert \mathcal{X} \rvert^n possible tapes. If we must reserve a codebook slot for every one of them, the cost of the system is nlogXn \log \lvert \mathcal{X} \rvert bits regardless of how skewed the language is, and all the structure we measured with H(X)H(X) 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 Xn\lvert \mathcal{X} \rvert^n, 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 numbersAsymptotic Equipartition Property
Object averagedThe values themselves, 1ni=1nXi\frac{1}{n}\sum_{i=1}^n X_iThe surprise of the values, 1nlogp(X1,,Xn)-\frac{1}{n}\log p(X_1, \ldots, X_n)
Converges toE[X]\mathbb{E}[X]H(X)H(X)
Physical readingThe average voltage of a long tape settles downThe average surprise of a long tape settles down

Because 1nlogp(X1,,Xn)-\frac{1}{n}\log p(X_1, \ldots, X_n) settles at H(X)H(X), the probability of whatever tape we actually observe settles at 2nH2^{-nH} — 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 X1,,XnX_1, \ldots, X_n are i.i.d. p(x)\sim p(x), then

Pr{(X1,,Xn):p(X1,,Xn)=2n(H±ϵ)}1\Pr \Big\{ (X_1, \ldots, X_n) : p(X_1, \ldots, X_n) = 2^{-n(H \pm \epsilon)} \Big\} \approx 1

ConventionTape notation

We write xnx^n as shorthand for a sequence x1,x2,,xnx_1, x_2, \ldots, x_n, and XnX^n for the corresponding random tape. So p(xn)p(x^n) is the probability the operator punches out that exact tape, and Xn\mathcal{X}^n is the set of all Xn\lvert \mathcal{X} \rvert^n tapes of length nn.


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, X{0,1}X \in \{0, 1\}, with p(1)=pp(1) = p and p(0)=qp(0) = q. Since keystrokes are i.i.d., the probability of a specific tape x1,x2,,xnx_1, x_2, \ldots, x_n is the product of the per-key probabilities:

p(x1,x2,,xn)=i=1np(xi)=pixi  qnixip(x_1, x_2, \ldots, x_n) = \prod_{i=1}^n p(x_i) = p^{\sum_i x_i} \; q^{\, n - \sum_i x_i}

ExampleA concrete tape

The tape (1,0,1,1,0,1)(1, 0, 1, 1, 0, 1) has probability p4q2p^4 q^2. A tape of six zeroes has probability q6q^6. These are wildly different numbers whenever pqp \neq q, so it is plainly not true that all 2n2^n tapes of length nn 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 2n2^n tapes have very different probabilities, the tapes that actually get printed almost all share roughly the same probability 2nH(p)2^{-nH(p)}. In this binary example that is just the statement that the number of 11s on a printed tape is close to npnp with high probability, and every tape with about npnp ones carries about the same probability.

RemarkThe self-referential flavour

We are asking for the probability p(X1,,Xn)p(X_1, \ldots, X_n) of the outcome X1,,XnX_1, \ldots, X_n, where the outcome is itself drawn according to that same distribution. This is insidiously self-referential, but perfectly well defined: p(Xn)p(X^n) is a random variable (a function of the XiX_i), 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 X1,X2,X_1, X_2, \ldots, we say the sequence converges to a random variable XX:

  1. In probability if for every ϵ>0\epsilon > 0, Pr{XnX>ϵ}0\Pr\{ \lvert X_n - X \rvert > \epsilon \} \rightarrow 0.
  2. In mean square if E(XnX)20\mathbb{E}(X_n - X)^2 \rightarrow 0.
  3. With probability 1 (also called almost surely) if Pr{limnXn=X}=1\Pr\{ \lim_{n \rightarrow \infty} X_n = X \} = 1.

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 ϵ\epsilon you like on the average surprise per keystroke; as the tape gets longer, the fraction of tapes whose average surprise misses H(X)H(X) by more than ϵ\epsilon 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 X1,X2,X_1, X_2, \ldots are i.i.d. p(x)\sim p(x), then

1nlogp(X1,X2,,Xn)H(X)in probability-\frac{1}{n} \log p(X_1, X_2, \ldots, X_n) \longrightarrow H(X) \quad \text{in probability}

IntuitionPhysical meaning

Read the left side as a measurement taken off the printed tape: take the whole tape, compute its surprise logp(tape)-\log p(\text{tape}), 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 H(X)H(X) 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 1nlogp(tape)H-\frac{1}{n}\log p(\text{tape}) \approx H rearranges to p(tape)2nHp(\text{tape}) \approx 2^{-nH}, the tape you are holding is overwhelmingly likely to be one with probability about 2nH2^{-nH}.

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 XiX_i are i.i.d., and logp()\log p(\cdot) is a fixed function applied to each one separately, so the random variables logp(X1),logp(X2),\log p(X_1), \log p(X_2), \ldots 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 p(x1,,xn)=i=1np(xi)p(x_1, \ldots, x_n) = \prod_{i=1}^n p(x_i), and the logarithm turns that product into a sum — the same additivity that forced hh to be a logarithm in the first place (see [[entropy-mutual-information#The three conditions we need on hh|the three conditions on hh]]):

1nlogp(X1,X2,,Xn)=1ni=1nlogp(Xi)-\frac{1}{n} \log p(X_1, X_2, \ldots, X_n) = -\frac{1}{n} \sum_{i=1}^n \log p(X_i)

The left side is the surprise of one enormous composite event; the right side is an ordinary sample mean of nn 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:

1ni=1nlogp(Xi)E[logp(X)]in probability-\frac{1}{n} \sum_{i=1}^n \log p(X_i) \longrightarrow -\mathbb{E}\big[\log p(X)\big] \quad \text{in probability}

Step 4: Recognize the expectation. By definition E[logp(X)]=xp(x)logp(x)=H(X)-\mathbb{E}[\log p(X)] = -\sum_x p(x) \log p(x) = H(X). Chaining Steps 2–4:

1nlogp(X1,,Xn)H(X)in probability-\frac{1}{n} \log p(X_1, \ldots, X_n) \longrightarrow H(X) \quad \text{in probability}


The typical set

The AEP says the sample entropy of a printed tape concentrates on H(X)H(X). That lets us physically partition the space of all possible tapes Xn\mathcal{X}^n into two piles: the tapes whose sample entropy came out close to HH, 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 Aϵ(n)A_\epsilon^{(n)}

The typical set Aϵ(n)A_\epsilon^{(n)} with respect to p(x)p(x) is the set of sequences (x1,x2,,xn)Xn(x_1, x_2, \ldots, x_n) \in \mathcal{X}^n with the property

2n(H(X)+ϵ)p(x1,x2,,xn)2n(H(X)ϵ)2^{-n(H(X) + \epsilon)} \le p(x_1, x_2, \ldots, x_n) \le 2^{-n(H(X) - \epsilon)}

ComponentDetail
SignatureAϵ(n)XnA_\epsilon^{(n)} \subseteq \mathcal{X}^n — a set of tapes, not a number.
Parametersnn, the tape length; ϵ\epsilon, the tolerance we allow on the per-keystroke surprise.
Membership testCompute the tape’s probability and check it lands in the band [2n(H+ϵ),2n(Hϵ)][2^{-n(H+\epsilon)},\, 2^{-n(H-\epsilon)}]. Taking 1nlog-\frac{1}{n}\log of all three parts turns this into the equivalent test Hϵ1nlogp(xn)H+ϵH - \epsilon \le -\frac{1}{n}\log p(x^n) \le H + \epsilon.

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 p(x)p(x) that its total surprise per key lands within ϵ\epsilon of H(X)H(X). 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 p(1)=0.9p(1) = 0.9. The single most likely tape of length nn is the all-ones tape, with probability 0.9n0.9^n — larger than any other individual tape. But its sample entropy is 1nlog(0.9n)=log(1/0.9)0.152-\frac{1}{n}\log(0.9^n) = \log(1/0.9) \approx 0.152 bits, while H(X)=H(0.9)0.469H(X) = H(0.9) \approx 0.469 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 11s is close to 0.90.9, 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 Aϵ(n)A_\epsilon^{(n)}

  1. If (x1,x2,,xn)Aϵ(n)(x_1, x_2, \ldots, x_n) \in A_\epsilon^{(n)}, then H(X)ϵ1nlogp(x1,x2,,xn)H(X)+ϵH(X) - \epsilon \le -\frac{1}{n} \log p(x_1, x_2, \ldots, x_n) \le H(X) + \epsilon
  2. Pr{Aϵ(n)}>1ϵ\Pr\big\{ A_\epsilon^{(n)} \big\} > 1 - \epsilon for nn sufficiently large.
  3. Aϵ(n)2n(H(X)+ϵ)\big\lvert A_\epsilon^{(n)} \big\rvert \le 2^{n(H(X) + \epsilon)}, where A\lvert A \rvert denotes the number of elements in the set AA.
  4. Aϵ(n)(1ϵ)2n(H(X)ϵ)\big\lvert A_\epsilon^{(n)} \big\rvert \ge (1 - \epsilon) 2^{n(H(X) - \epsilon)} for nn 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 2nH2^{nH} elements (properties 3 and 4 — so indexing it takes about nHnH bits rather than nlogXn \log \lvert \mathcal{X} \rvert).

ProofProperty 1 — immediate from the definition

Start from the membership condition:

2n(H+ϵ)p(x1,,xn)2n(Hϵ)2^{-n(H + \epsilon)} \le p(x_1, \ldots, x_n) \le 2^{-n(H - \epsilon)}

Take log\log of all three parts (monotone, so inequalities are preserved):

n(H+ϵ)logp(x1,,xn)n(Hϵ)-n(H + \epsilon) \le \log p(x_1, \ldots, x_n) \le -n(H - \epsilon)

Multiply through by 1n-\frac{1}{n}, which is negative and therefore flips both inequalities:

Hϵ1nlogp(x1,,xn)H+ϵH - \epsilon \le -\frac{1}{n} \log p(x_1, \ldots, x_n) \le H + \epsilon

So the “probability band” definition and the “sample entropy within ϵ\epsilon” 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 ϵ\epsilon-δ\delta form. Theorem (AEP) says 1nlogp(X1,,Xn)H(X)-\frac{1}{n}\log p(X_1, \ldots, X_n) \to H(X) in probability. By the definition of convergence in probability, for any δ>0\delta > 0 there exists an n0n_0 such that for all nn0n \ge n_0:

Pr{1nlogp(X1,X2,,Xn)H(X)<ϵ}>1δ\Pr \left\{ \left\lvert -\frac{1}{n} \log p(X_1, X_2, \ldots, X_n) - H(X) \right\rvert < \epsilon \right\} > 1 - \delta

Step 2: Recognize the event. By Property 1, the event inside that probability — sample entropy within ϵ\epsilon of H(X)H(X)is the event (X1,,Xn)Aϵ(n)(X_1, \ldots, X_n) \in A_\epsilon^{(n)}. So the displayed line already reads Pr{Aϵ(n)}>1δ\Pr\{A_\epsilon^{(n)}\} > 1 - \delta.

Step 3: Set δ=ϵ\delta = \epsilon. The AEP holds for every δ>0\delta > 0, so we are free to choose δ=ϵ\delta = \epsilon, giving Pr{Aϵ(n)}>1ϵ\Pr\{A_\epsilon^{(n)}\} > 1 - \epsilon for nn 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.

1=xnXnp(xn)1 = \sum_{x^n \in \mathcal{X}^n} p(x^n)

Step 2: Discard the atypical tapes. Restricting a sum of non-negative terms to a subset can only shrink it:

1xnAϵ(n)p(xn)1 \ge \sum_{x^n \in A_\epsilon^{(n)}} p(x^n)

Step 3: Replace each term by its floor. By the membership definition, every typical tape has p(xn)2n(H+ϵ)p(x^n) \ge 2^{-n(H + \epsilon)}:

1xnAϵ(n)2n(H(X)+ϵ)1 \ge \sum_{x^n \in A_\epsilon^{(n)}} 2^{-n(H(X) + \epsilon)}

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:

12n(H(X)+ϵ)Aϵ(n)1 \ge 2^{-n(H(X) + \epsilon)} \big\lvert A_\epsilon^{(n)} \big\rvert

Step 5: Rearrange.

Aϵ(n)2n(H(X)+ϵ)\big\lvert A_\epsilon^{(n)} \big\rvert \le 2^{n(H(X) + \epsilon)}

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 nn sufficiently large,

1ϵ<Pr{Aϵ(n)}=xnAϵ(n)p(xn)1 - \epsilon < \Pr\big\{A_\epsilon^{(n)}\big\} = \sum_{x^n \in A_\epsilon^{(n)}} p(x^n)

Step 2: Replace each term by its ceiling. By the membership definition, every typical tape has p(xn)2n(Hϵ)p(x^n) \le 2^{-n(H - \epsilon)}:

1ϵ<xnAϵ(n)2n(H(X)ϵ)1 - \epsilon < \sum_{x^n \in A_\epsilon^{(n)}} 2^{-n(H(X) - \epsilon)}

Step 3: Collapse the sum into a count.

1ϵ<2n(H(X)ϵ)Aϵ(n)1 - \epsilon < 2^{-n(H(X) - \epsilon)} \big\lvert A_\epsilon^{(n)} \big\rvert

Step 4: Rearrange.

Aϵ(n)(1ϵ)2n(H(X)ϵ)\big\lvert A_\epsilon^{(n)} \big\rvert \ge (1 - \epsilon) 2^{n(H(X) - \epsilon)}

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 2nH2^{nH} 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 xnx^n 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 nlogXn \log \lvert \mathcal{X} \rvert 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.

PileSizeIndex costFlagTotal length
Typical Aϵ(n)A_\epsilon^{(n)}2n(H+ϵ)\le 2^{n(H + \epsilon)}n(H+ϵ)+1\le n(H + \epsilon) + 1 bits0n(H+ϵ)+2\le n(H + \epsilon) + 2 bits
Atypical Aϵ(n)c{A_\epsilon^{(n)}}^cXn\le \lvert \mathcal{X} \rvert^nnlogX+1\le n \log \lvert \mathcal{X} \rvert + 1 bits1nlogX+2\le n \log \lvert \mathcal{X} \rvert + 2 bits

NoteWhere the two extra bits come from

One bit is the flag. The other is a ceiling: indexing 2n(H+ϵ)2^{n(H+\epsilon)} items needs n(H+ϵ)\lceil n(H + \epsilon) \rceil bits, and n(H+ϵ)n(H + \epsilon) need not be an integer, so n(H+ϵ)+1n(H + \epsilon) + 1 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 Xn\mathcal{X}^n, ignoring the fact that Aϵ(n)c\lvert {A_\epsilon^{(n)}}^c \rvert is strictly smaller than Xn\lvert \mathcal{X}^n \rvert. 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 ϵ\epsilon, so the waste is multiplied by almost nothing.

Expected codeword length

Let l(xn)l(x^n) be the length of the codeword assigned to tape xnx^n. Take nn large enough that Pr{Aϵ(n)}1ϵ\Pr\{A_\epsilon^{(n)}\} \ge 1 - \epsilon.

TheoremSource coding via the typical set

Let XnX^n be i.i.d. p(x)\sim p(x) and let ϵ>0\epsilon > 0. Then there exists a code mapping sequences xnx^n of length nn into binary strings such that the mapping is one-to-one (and therefore invertible) and

E[1nl(Xn)]H(X)+ϵ\mathbb{E}\left[ \frac{1}{n} l(X^n) \right] \le H(X) + \epsilon'

for nn sufficiently large. That is: we can represent tapes XnX^n using about nH(X)nH(X) 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:

E[l(Xn)]=xnp(xn)l(xn)\mathbb{E}\big[l(X^n)\big] = \sum_{x^n} p(x^n)\, l(x^n)

Step 2: Split the sum along the partition. Every tape is in exactly one pile, so the sum splits cleanly with no double counting:

=xnAϵ(n)p(xn)l(xn)  +  xnAϵ(n)cp(xn)l(xn)= \sum_{x^n \in A_\epsilon^{(n)}} p(x^n)\, l(x^n) \;+\; \sum_{x^n \in {A_\epsilon^{(n)}}^c} p(x^n)\, l(x^n)

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:

xnAϵ(n)p(xn)(n(H+ϵ)+2)  +  xnAϵ(n)cp(xn)(nlogX+2)\le \sum_{x^n \in A_\epsilon^{(n)}} p(x^n)\big(n(H + \epsilon) + 2\big) \;+\; \sum_{x^n \in {A_\epsilon^{(n)}}^c} p(x^n)\big(n \log \lvert \mathcal{X} \rvert + 2\big)

Step 4: Collapse each sum into a probability. The length factors are now constants within each pile and pull out, leaving bare sums of p(xn)p(x^n) over each pile — which are by definition the piles’ probabilities:

=Pr{Aϵ(n)}(n(H+ϵ)+2)  +  Pr{Aϵ(n)c}(nlogX+2)= \Pr\big\{A_\epsilon^{(n)}\big\}\big(n(H + \epsilon) + 2\big) \;+\; \Pr\big\{{A_\epsilon^{(n)}}^c\big\}\big(n \log \lvert \mathcal{X} \rvert + 2\big)

Step 5: Bound the two probabilities — this is the step that does the work. For the typical term use the trivial bound Pr{Aϵ(n)}1\Pr\{A_\epsilon^{(n)}\} \le 1 (we are happy to pay full price on the cheap pile). For the atypical term use Property 2, Pr{Aϵ(n)c}ϵ\Pr\{{A_\epsilon^{(n)}}^c\} \le \epsilon (the expensive pile is charged at a rate of ϵ\epsilon):

n(H+ϵ)+ϵnlogX+2\le n(H + \epsilon) + \epsilon\, n \log \lvert \mathcal{X} \rvert + 2

Step 6: Collect into a single ϵ\epsilon'. Factor out nn:

=n(H+ϵ+ϵlogX+2nϵ)=n(H+ϵ)= n\left(H + \underbrace{\epsilon + \epsilon \log \lvert \mathcal{X} \rvert + \frac{2}{n}}_{\epsilon'}\right) = n(H + \epsilon')

Step 7: Check ϵ\epsilon' can be made arbitrarily small. The order matters. First choose ϵ\epsilon small enough to crush ϵ+ϵlogX\epsilon + \epsilon \log \lvert \mathcal{X} \rvert — note this is possible because logX\log \lvert \mathcal{X} \rvert is a fixed constant of the alphabet, not something growing with nn. Then, with ϵ\epsilon fixed, choose nn large enough to crush the 2/n2/n term. Dividing through by nn gives the theorem.

IntuitionWhat this buys the telecom company

A naive engineer reserves a codeword slot for all Xn\lvert \mathcal{X} \rvert^n tapes and pays nlogXn \log \lvert \mathcal{X} \rvert bits per message no matter what. This scheme pays about nH(X)nH(X) bits per message instead, and the gap n(logXH(X))n\big(\log \lvert \mathcal{X} \rvert - H(X)\big) 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, Aϵ(n)A_\epsilon^{(n)} 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 nHnH 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 Bδ(n)B_\delta^{(n)}

For each n=1,2,n = 1, 2, \ldots, let Bδ(n)XnB_\delta^{(n)} \subset \mathcal{X}^n be the smallest set with

Pr{Bδ(n)}1δ\Pr\big\{B_\delta^{(n)}\big\} \ge 1 - \delta

IntuitionHow Bδ(n)B_\delta^{(n)} is built, and why it differs from Aϵ(n)A_\epsilon^{(n)}

To make a high-probability set as small as possible you take the most probable tapes first and keep going until you have accumulated 1δ1 - \delta of the probability. So Bδ(n)B_\delta^{(n)} is a greedy top-of-the-list set, whereas Aϵ(n)A_\epsilon^{(n)} is a band set. They are built by genuinely different rules, and they are not the same set — Bδ(n)B_\delta^{(n)} contains the single most probable tapes, which as we saw can be atypical.

TheoremSize of the smallest high-probability set

Let X1,X2,,XnX_1, X_2, \ldots, X_n be i.i.d. p(x)\sim p(x). For δ<12\delta < \frac{1}{2} and any δ>0\delta' > 0, if Pr{Bδ(n)}>1δ\Pr\{B_\delta^{(n)}\} > 1 - \delta, then

1nlogBδ(n)>Hδ\frac{1}{n} \log \big\lvert B_\delta^{(n)} \big\rvert > H - \delta'

for nn 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 1δ1 - \delta must have a significant intersection with Aϵ(n)A_\epsilon^{(n)} (since Aϵ(n)A_\epsilon^{(n)} itself carries nearly all the probability, and δ<12\delta < \frac{1}{2} prevents Bδ(n)B_\delta^{(n)} from dodging it), and every tape in that intersection carries probability at most 2n(Hϵ)2^{-n(H - \epsilon)} — so covering that much probability with such small pieces forces at least about 2nH2^{nH} pieces.

So Bδ(n)B_\delta^{(n)} must have at least 2nH2^{nH} elements, to first order in the exponent — while Aϵ(n)A_\epsilon^{(n)} has 2n(H±ϵ)2^{n(H \pm \epsilon)} 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 anbna_n \doteq b_n means

limn1nloganbn=0\lim_{n \rightarrow \infty} \frac{1}{n} \log \frac{a_n}{b_n} = 0

IntuitionWhat \doteq deliberately ignores

This says ana_n and bnb_n agree in the exponent, not in the number. Two sets of sizes 2nH2^{nH} and n1002nHn^{100} \cdot 2^{nH} satisfy anbna_n \doteq b_n, because dividing the log by nn kills any polynomial factor. For an engineer this is exactly the right resolution: what they pay is log(set size)\log(\text{set size}) 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 δn0\delta_n \rightarrow 0 and ϵn0\epsilon_n \rightarrow 0, then

Bδn(n)Aϵn(n)2nH\big\lvert B_{\delta_n}^{(n)} \big\rvert \doteq \big\lvert A_{\epsilon_n}^{(n)} \big\rvert \doteq 2^{nH}

Illustration: where the two sets actually differ

Take a Bernoulli sequence X1,X2,,XnX_1, X_2, \ldots, X_n with parameter p=0.9p = 0.9, i.e. a binary operator who types 11 with probability 0.90.9.

Aϵ(n)A_\epsilon^{(n)}Bδ(n)B_\delta^{(n)}
RuleTapes whose proportion of 11s is close to 0.90.9The most probable tapes, taken greedily until probability 1δ1 - \delta is covered
Contains all-ones tape?No — its sample entropy is 0.152\approx 0.152 bits, far from H(0.9)0.469H(0.9) \approx 0.469Yes — it is the single most likely tape of all
Contains the 90%\approx 90\%-ones tapes?Yes, by constructionYes — forced by the theorem
Size2nH\doteq 2^{nH}2nH\doteq 2^{nH}

IntuitionThe reconciliation

The two sets are not equal — Bδ(n)B_\delta^{(n)} contains the all-ones tape and Aϵ(n)A_\epsilon^{(n)} does not. But both are forced to contain the bulk of the tapes with about 90%90\% 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 H(X)H(X) 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 HH), 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

ObjectStatementReads as
AEP1nlogp(Xn)H(X)-\frac{1}{n}\log p(X^n) \to H(X) in probabilitySample entropy of a long tape converges to the source’s blueprint entropy.
Typical set2n(H+ϵ)p(xn)2n(Hϵ)2^{-n(H+\epsilon)} \le p(x^n) \le 2^{-n(H-\epsilon)}Tapes whose statistics look ordinary for this source.
ProbabilityPr{Aϵ(n)}>1ϵ\Pr\{A_\epsilon^{(n)}\} > 1 - \epsilonThe typical pile is almost everything that happens.
Size (upper)Aϵ(n)2n(H+ϵ)\lvert A_\epsilon^{(n)} \rvert \le 2^{n(H+\epsilon)}There are not many realistic tapes.
Size (lower)Aϵ(n)(1ϵ)2n(Hϵ)\lvert A_\epsilon^{(n)} \rvert \ge (1-\epsilon)2^{n(H-\epsilon)}But there are not too few either — the count really is 2nH\approx 2^{nH}.
Source codeE[1nl(Xn)]H(X)+ϵ\mathbb{E}\big[\tfrac{1}{n} l(X^n)\big] \le H(X) + \epsilon'A one-to-one code averaging about nHnH bits per tape exists.
OptimalityBδ(n)Aϵ(n)2nH\lvert B_\delta^{(n)} \rvert \doteq \lvert A_\epsilon^{(n)} \rvert \doteq 2^{nH}No smaller high-probability set beats the typical set in the exponent.

Constants to keep to hand:

  • Typical codeword length: n(H+ϵ)+2\le n(H + \epsilon) + 2 bits (index ++ flag ++ ceiling).
  • Atypical codeword length: nlogX+2\le n \log \lvert \mathcal{X} \rvert + 2 bits.
  • Slack in the source coding theorem: ϵ=ϵ+ϵlogX+2n\epsilon' = \epsilon + \epsilon \log \lvert \mathcal{X} \rvert + \frac{2}{n} — shrink ϵ\epsilon first, then grow nn.

References

  • [[lit/cover2006-elements|Cover & Thomas, Elements of Information Theory]] — Chapter 3

← All notes