46.02.01 · information-theory / source-coding

The Asymptotic Equipartition Property (AEP) and Strongly Typical Sequences

shipped3 tiersLean: none

Anchor (Master): Cover & Thomas 2006 Elements of Information Theory 2e (Wiley) §3.1-3.4; Csiszar & Korner 2011 Information Theory: Coding Theorems for Discrete Memoryless Systems 2e (Cambridge) §1.2-2.1; Shannon 1948 A Mathematical Theory of Communication §7 (the source coding theorem foundation)

Intuition Beginner

Imagine flipping a fair coin 100 times. There are possible sequences of heads and tails. That is an astronomically large number. But almost all of those sequences look boring: roughly 50 heads and 50 tails, in some order. The sequences that are "surprising" — all heads, or alternating HTHTHT... — are vanishingly rare.

The asymptotic equipartition property (AEP) makes this precise. It says that when you draw independent samples from any distribution, the resulting sequence almost certainly lands in a small collection called the typical set. Each sequence in the typical set has approximately the same probability, close to , where is the entropy of one draw. The typical set is tiny compared to the full space of all possible sequences, yet it carries almost all the probability.

Think of it this way. The full space of 100 coin flips has elements. The typical set has about elements, where is the entropy per flip. For a fair coin, and the typical set is most of the space. For a biased coin with , the typical set is only about out of — exponentially smaller, yet still carrying nearly all the probability mass.

This is why data compression works. You only need to give distinct labels (codewords) to the sequences in the typical set. Since the typical set has about elements, you need about bits to label them all. The remaining sequences are so unlikely that you can afford to give them all the same default label, at negligible cost. The AEP is the theorem that justifies this strategy: it tells you the typical set exists, how big it is, and that it carries nearly all the probability.

Visual Beginner

Figure: a bar chart showing all binary sequences of length 4 drawn from a biased coin with for heads. The x-axis lists the 16 sequences. The y-axis shows probability. A horizontal band highlights the typical set: sequences with 1 to 3 heads (the ones whose per-symbol log-probability is close to bits). The atypical sequences (all heads, all tails) sit far outside the band.

| Sequence length | Alphabet size | Full space | Typical set size | Ratio | |---|---|---|---|---| | Fair coin, | 2 | | | (entropy = 1, almost everything is typical) | | Biased coin (), | 2 | | | 0.025 | | Fair die, | 6 | | | | | Loaded die, | 6 | | | |

The pattern: the gap between the full space and the typical set grows exponentially with . For a source with entropy less than the maximum, nearly all sequences are atypical, yet the atypical ones collectively carry almost no probability.

Worked example Beginner

A biased coin lands heads with probability and tails with probability . The entropy is bits. We flip the coin times.

The probability of any specific sequence is where is the number of heads. The per-symbol log-probability is .

Step 1. Compute for each possible number of heads:

  • (HHHH): bits. Far from .
  • (e.g., HHHT): bits. Close to .
  • (e.g., HHTT): bits. Less close.
  • (e.g., HTTT): bits. Far.
  • (TTTT): bits. Far.

Step 2. Choose . The typical set is . The interval is . Sequences with (per-symbol info ) and (per-symbol info ) fall in the typical set.

Step 3. Count and weigh. There are sequences with and with , giving . The full space has sequences. The probability of the typical set is .

With only the concentration is weak — , not yet close to 1. As grows, the law of large numbers forces for any fixed , and the typical set size concentrates near .

Check your understanding Beginner

Formal definition Intermediate+

Let be drawn i.i.d. from a distribution on a finite alphabet with entropy . Write and for a specific realisation.

Definition (Information per symbol). The per-symbol log-likelihood of a sequence is

where the product form follows from independence.

Definition (Typical set). For and positive integer , the typical set is

Equivalently, if and only if

Counterexamples to common slips

  • The typical set is not the set of high-probability sequences. The highest-probability sequence is the mode of the product distribution, which for a biased coin is all-heads. The typical set excludes the mode when . The typical set contains sequences whose per-symbol information is near , not those with highest absolute probability.

  • Typicality does not require the sequence to "look random." For a uniform distribution on , every sequence is typical. For a highly biased distribution, a typical sequence still has most symbols equal to the most likely value — that is exactly what the entropy predicts.

  • The typical set is not uniquely defined. It depends on the choice of and . Different give different sets. The theorem says that for any fixed , the typical set eventually (for large enough ) captures most of the probability.

Key theorem with proof Intermediate+

Theorem (AEP). Let be drawn i.i.d. from a distribution with entropy . Then

i.e., for every ,

Proof. Since are i.i.d., the random variables are also i.i.d. The expected value is

The per-symbol log-probability is the sample mean:

Since the are i.i.d. with finite mean (finiteness follows from for finite alphabets), the weak law of large numbers 37.02.01 gives in probability. This is exactly the AEP.

Theorem (Properties of the typical set). For any :

  1. Probability bound. For sufficiently large, .

  2. Cardinality upper bound. .

  3. Cardinality lower bound. For sufficiently large, .

Proof of (1). By the AEP, in probability. For any , there exists such that for all :

Taking complements: .

Proof of (2). For any , we have . Since the total probability of is at most 1:

giving .

Proof of (3). For sufficiently large, . Also, for any , . Therefore:

giving .

Bridge. The AEP builds toward the source coding theorem in 46.02.02 by establishing that only codewords are needed to describe symbols with negligible error probability, making the operational compression limit. It appears again in the channel coding theorem 46.03.01 where joint typicality between input and output sequences replaces single-sequence typicality, and the mutual information replaces as the governing exponent. The foundational reason the AEP works is the law of large numbers applied to the information random variables , which has expected value ; this is exactly the mechanism by which the chain rule from 46.01.01 telescopes the information content of a sequence into a sum of independent terms. The AEP generalises to the method of types and large deviations 37.07.05, where the exponent for atypical behaviour is the relative entropy ; the central insight is that entropy governs not just average uncertainty but the geometry of the probability landscape — the typical set is an exponentially small subset of the full space that carries nearly all the mass.

Exercises Intermediate+

Lean formalization Intermediate+

Mathlib provides the weak law of large numbers for i.i.d. integrable random variables (ProbabilityTheory.lawOfLargeNumbers) and the basic PMF type for discrete distributions. However, it does not define the typical set as a measurable set indexed by and , nor does it prove the AEP theorem that in probability. The cardinality bounds are absent. Strong typicality — the refinement where individual letter frequencies are controlled — is not formalised. The foundational gap is the convergence-in-probability statement for the empirical entropy of an i.i.d. sequence, plus the combinatorial bounds on the typical set. A Codex.InformationTheory.AEP module proving the AEP from the law of large numbers and deriving the cardinality bounds would be the load-bearing step; this unit ships without it.

Advanced results Master

Strong typicality and the method of types

The weak AEP uses convergence in probability of to . Strong typicality refines this by controlling the empirical distribution (the type) of each sequence individually.

Definition (Type). For a sequence , the type (or empirical distribution) is , where is the number of times symbol appears in .

Definition (Strongly typical set). For , the strongly typical set is

Strong typicality implies weak typicality: if then for where (proved in the exercises). The converse is false: a sequence can have the right per-symbol log-probability without having the right letter frequencies.

The strong version is needed for proving the channel coding theorem and the rate-distortion theorem. In the channel coding setting, the joint typicality of input-output pairs requires that both marginals and the joint type are close to their expected distributions, which weak typicality cannot guarantee.

Theorem (Size of the type class). For a type with for integers , the number of sequences with type is

By Stirling's approximation, , where is the entropy of the type class distribution. This gives the method-of-types bound: the number of types is polynomial in (at most ), while the number of sequences in each type class is exponential with exponent .

The high-probability set and its optimality

The typical set is one convenient high-probability set, but is it the smallest? The answer is: up to polynomial factors, yes.

Theorem (Size of the smallest high-probability set). Define to be the smallest subset of with . Then for any and , for sufficiently large:

Proof sketch. The upper bound follows from the fact that the typical set is a high-probability set with size at most . The lower bound: any set with probability must contain at least typical sequences (since the atypical sequences contribute at most probability), and each typical sequence has probability at most .

This means the typical set is near-optimal: no other high-probability set can be substantially smaller. The exponent is intrinsic to the source, not an artifact of the typical-set construction.

Convergence rates

The AEP is a qualitative result (convergence in probability). Quantitative bounds come from large deviations. By the Chernoff bound applied to :

where is the varentropy. The varentropy governs the rate of concentration: it measures how spread out the information content is around its mean. For a fair coin, (since is deterministic at 1 bit); for a biased coin, and grows as the bias increases.

The AEP for stationary ergodic sources

The AEP extends beyond i.i.d. sources. For a stationary ergodic source with entropy rate , the Shannon-McMillan-Breiman theorem states:

This is an almost-sure convergence, stronger than the convergence in probability for the i.i.d. case. The proof uses the ergodic theorem (Birkhoff or the martingale convergence theorem applied to the conditional densities). For i.i.d. sources, and the SMB theorem reduces to the strong law of large numbers.

Synthesis. The AEP is the foundational reason entropy has operational meaning; the typical set of size is near-optimal among all high-probability sets, and the source coding theorem 46.02.02 formalises this as a compression limit of bits per symbol. Strong typicality refines the picture by controlling individual letter frequencies, which builds toward the channel coding theorem 46.03.01 where joint typicality between input and output sequences is the central tool. The varentropy governs the convergence rate, connecting to large deviations 37.07.05 where the exponent for atypical events is the relative entropy . The central insight is that entropy is not merely an average — it is the exponent governing the geometry of high-dimensional probability distributions, and the AEP makes this precise by showing that the effective support of draws is a set of size , exponentially smaller than the full space whenever .

Full proof set Master

Proposition (Strong typicality implies weak typicality). Let be the strongly typical set and the weakly typical set. Then where .

Proof. For any , define . By strong typicality, for each . Compute:

Setting gives the result. For the refined bound with per symbol, the same argument with yields .

Proposition (Number of types). The number of distinct types for sequences of length from an alphabet of size is at most .

Proof. A type is determined by the counts for each , subject to with each . The number of such integer tuples is . Each tuple defines at most one type, so the total number of types is at most .

Proposition (Probability of a type class). For any type with counts , the probability that an i.i.d. sequence has type satisfies

where is the KL divergence.

Proof. The probability of any specific sequence with type is . The number of sequences with type is the multinomial coefficient by Stirling. Therefore:

Since , this simplifies to . The polynomial factors are bounded by , giving the stated bounds.

Connections Master

  • 46.01.01 — The AEP uses the entropy defined in that unit, and the chain rule to decompose into i.i.d. terms for the law-of-large-numbers argument.
  • 37.02.01 — The weak law of large numbers is the engine of the AEP; the convergence is an application of the WLLN to the information random variables .
  • 46.02.02 — Shannon's source coding theorem uses the AEP to prove that bits per symbol suffice for compression; the typical set of size is the set that the optimal code must be able to index.
  • 46.03.01 — The channel coding theorem extends the AEP to joint typicality of input-output pairs , replacing with as the governing exponent.
  • 46.01.02 — The relative entropy measures the exponent for "q-typical" sets under distribution ; the AEP is the case where .
  • 37.07.05 — Sanov's theorem in large deviations gives the precise exponential rate for atypical types as ; the method of types developed here is the combinatorial engine behind Sanov's theorem.

Historical & philosophical context Master

The AEP has its roots in Shannon's 1948 paper "A Mathematical Theory of Communication" (Bell System Technical Journal 27, 379-423 and 623-656). In Section 7, Shannon argued informally that long sequences from a discrete source fall into two classes: a relatively small number of high-probability sequences and a vast number of low-probability ones. He used this to derive the source coding theorem, though he did not formally define the typical set or prove the AEP as a separate theorem.

The formal AEP theorem and the definition of the typical set appeared in the information-theory textbook tradition through the 1960s and 1970s. Cover and Thomas (1991, 2nd edition 2006) gave the standard presentation in their Chapter 3, proving the AEP from the weak law of large numbers and deriving the cardinality and probability bounds.

Strong typicality was introduced independently by Wolfowitz (1961, Coding Theorems of Information Theory) and developed systematically by Csiszar and Korner (1981, Information Theory: Coding Theorems for Discrete Memoryless Systems). The method of types — the combinatorial framework for counting sequences by their empirical distributions — is due to Csiszar, who used it to give elegant proofs of the channel coding theorem, the rate-distortion theorem, and Sanov's theorem. The key insight of the method of types is that the number of types is polynomial in , while each type class is exponential, so the combinatorics simplify dramatically.

The Shannon-McMillan-Breiman theorem extends the AEP from i.i.d. sources to stationary ergodic sources. Shannon (1948) stated the result for Markov chains. McMillan (1953, "The Basic Theorems of Information Theory") proved convergence in probability for stationary ergodic sources. Breiman (1957, "The Individual Ergodic Theorem of Information Theory") proved almost-sure convergence. The SMB theorem is one of the deepest results in ergodic theory and information theory, connecting the entropy rate of a process to the asymptotic behaviour of its sample paths.

The varentropy — the variance of the information random variable — governs the convergence rate of the AEP. Kontoyiannis and Verdu (2014, "Optimal Exponent for the AEP") showed that the varentropy determines the precise exponent in the large-deviation probability of the atypical event, sharpening the qualitative AEP to a quantitative bound.

Bibliography Master

@article{shannon1948,
  author  = {Shannon, C. E.},
  title   = {A Mathematical Theory of Communication},
  journal = {Bell System Technical Journal},
  volume  = {27},
  pages   = {379--423 and 623--656},
  year    = {1948},
}
@book{cover-thomas2006,
  author    = {Cover, T. M. and Thomas, J. A.},
  title     = {Elements of Information Theory},
  edition   = {2nd},
  publisher = {Wiley},
  year      = {2006},
}
@book{csiszar-korner2011,
  author    = {Csisz{\'a}r, I. and K{\"o}rner, J.},
  title     = {Information Theory: Coding Theorems for Discrete Memoryless Systems},
  edition   = {2nd},
  publisher = {Cambridge University Press},
  year      = {2011},
}
@book{wolfowitz1961,
  author    = {Wolfowitz, J.},
  title     = {Coding Theorems of Information Theory},
  publisher = {Springer},
  year      = {1961},
}
@article{mcmillan1953,
  author  = {McMillan, B.},
  title   = {The Basic Theorems of Information Theory},
  journal = {Annals of Mathematical Statistics},
  volume  = {25},
  pages   = {241--252},
  year    = {1953},
}
@article{breiman1957,
  author  = {Breiman, L.},
  title   = {The Individual Ergodic Theorem of Information Theory},
  journal = {Annals of Mathematical Statistics},
  volume  = {28},
  pages   = {809--811},
  year    = {1957},
}
@article{kontoyiannis-verdu2014,
  author  = {Kontoyiannis, I. and Verd{\'u}, S.},
  title   = {Optimal Exponent for the AEP},
  journal = {IEEE Transactions on Information Theory},
  volume  = {60},
  number  = {11},
  pages   = {6753--6759},
  year    = {2014},
}