The Method of Types and Sanov's Theorem (IT formulation)
Anchor (Master): Cover & Thomas 2006 Elements of Information Theory 2e (Wiley) §11.1-11.5; Csiszar 1998 The Method of Types IEEE Trans. Info. Theory 44(6) 2505-2523; Dembo & Zeitouni 1998 Large Deviations Techniques and Applications 2e (Springer) §2.1-2.3
Intuition Beginner
Flip a coin 100 times. You get some number of heads — say 47. The "type" of the sequence is just the histogram: 47 heads, 53 tails. Two sequences have the same type if they have the same histogram, regardless of the order of outcomes.
There are possible sequences but only 101 possible types (0 heads, 1 head, ..., 100 heads). That is a huge collapse. Most types are boring — they cluster near 50 heads, 50 tails. The surprising types (like 0 heads) are extremely rare.
How many sequences share a given type? If the type says 50 heads and 50 tails, the number of such sequences is "100 choose 50", which is enormous — roughly divided by the square root of . If the type says 0 heads, there is only one sequence (all tails).
Sanov's theorem answers a deeper question. Suppose the coin is fair, and you ask: what is the probability that the empirical histogram lands in some unusual set, like "at least 70 heads out of 100"? The answer is exponential in , with the rate given by a KL divergence. The least-unusual histogram in the set (in this case, exactly 70-30) determines the rate, and that rate is where and .
The method of types reframes Sanov's theorem in purely combinatorial language. No integrals, no measure theory — just counting sequences and bounding multinomial coefficients. This combinatorial clarity makes it the preferred tool in information theory.
The method of types has a philosophical implication: it separates the combinatorial structure of the problem (how many sequences have a given type) from the probabilistic structure (how likely each sequence is under the true distribution). The combinatorial part is governed by entropy, and the probabilistic part by KL divergence. These two quantities are the pillars of information theory, and the method of types shows exactly how they interact.
Visual Beginner
Figure: a grid of 100 cells, each coloured black (heads) or white (tails). Three panels show: (1) a typical sequence with 48 heads and 52 tails, scattered randomly; (2) a type class showing all rearrangements of the same histogram are equally likely; (3) an atypical sequence with 90 heads and 10 tails, concentrated black.
| Sequence type | Number of heads | Number of such sequences | Probability (fair coin) |
|---|---|---|---|
| 50-50 | 50 | about 0.08 | |
| 60-40 | 60 | about 0.011 | |
| 70-30 | 70 | about 0.00002 | |
| 90-10 | 90 | extremely small | |
| 100-0 | 100 | 1 |
The number of sequences drops precipitously as the type becomes more extreme, and the probability drops even faster because each individual sequence has probability .
Worked example Beginner
A fair die is rolled 12 times. The type of the outcome sequence is the count of each face (1 through 6). How many sequences have type — meaning three 1s, two each of 2 through 5, and one 6?
The count is a multinomial coefficient: the number of ways to arrange 12 items where three are of one kind, two each of four kinds, and one of the last kind.
The answer is .
Each such sequence has probability because the die is fair. So the probability of seeing exactly this type is .
Compare with the most likely type, : the count is , and the probability is about . The difference is small because 12 is a short sequence. For , the concentration around the uniform type would be much sharper.
Check your understanding Beginner
Formal definition Intermediate+
Let be a finite alphabet with and let be an i.i.d. sequence with on .
Definition (Type). The type (or empirical distribution) of a sequence is the probability distribution on defined by
A distribution on is called an -type if for all .
Definition (Type class). The type class of a distribution is
Definition (Probability under ). For any -type and true distribution ,
Counterexamples to common slips
Types are distributions on the source alphabet, not on the integers. The type lives in the probability simplex , not in itself.
Sanov's theorem is a large-deviation result, not a limit theorem. It gives the exponential rate at which probabilities vanish, not the limiting distribution. The limiting distribution of the type is the true distribution (by the law of large numbers); Sanov quantifies the exponentially rare deviations.
The infimum in Sanov's theorem is over the closure of the set . For open sets, the equality is exact (); for closed sets, the upper and lower bounds match. For general sets, taking the interior and closure gives two-sided bounds.
Key theorem with proof Intermediate+
Theorem (Sanov's theorem, IT formulation). Let be i.i.d. on a finite alphabet . Let be a set of probability distributions on . Then
where denotes equality to first order in the exponent: .
Proof sketch. We prove the upper bound; the lower bound follows by restricting to a single type.
Upper bound. The number of types is at most , which is polynomial in . For each type ,
Summing over all types in :
Since is polynomial in , it does not affect the exponential rate:
Lower bound. For any that is an -type (or can be approximated by -types):
Therefore .
Bridge. The method of types builds toward universal source coding in this same unit, where the type class size bound directly controls the rate of a code that achieves entropy without knowing the true distribution. This is exactly the combinatorial mechanism that makes the two-stage code (describe the type, then describe the sequence within the type class) achieve the entropy rate with overhead that vanishes per symbol. The foundational reason Sanov's theorem matters for information theory is that KL divergence appears as both the large-deviation rate function here and the redundancy of mismatched codes in 46.02.03, and the bridge is the counting argument that connects combinatorial type classes to exponential probabilities. The central insight generalises to conditional types and the method of types for channel coding in 46.04.03, where Sanov's theorem governs the error exponents, and appears again in 46.04.01 as the engine behind the Stein lemma.
Exercises Intermediate+
Lean formalization Intermediate+
Mathlib lacks the type-theoretic machinery for the method of types. There is no definition of empirical distribution as a map from to the probability simplex, no type-class size bounds, and no Sanov's theorem. The multinomial coefficient exists via Finset.ncard and combinatorial identities, but the information-theoretic bounds connecting type-class size to entropy are absent. A Codex.InformationTheory.MethodOfTypes module would need to define the type operator, prove the size bounds using Stirling's approximation, and derive Sanov's theorem as a corollary. This unit ships without formal verification.
Advanced results Master
Conditional types and the conditional method of types
The method of types extends to pairs of sequences. Given sequences and , the joint type is and the conditional type is the collection of transition counts from each to each .
The conditional type class (the set of with given conditional type given ) has size approximately , paralleling the unconditional bound. This gives a Sanov-type theorem for conditional distributions:
where is the true conditional distribution and .
Universal source coding
The two-stage code (type header + sequence index within type class) achieves the entropy rate for any source distribution without knowing in advance. The per-symbol redundancy is , which vanishes as block length grows.
This universality result is the information-theoretic analogue of the minimum description length (MDL) principle: the best model for the data is the one that minimises the total description length, which is the sum of the model complexity (the type header) and the data complexity given the model (the sequence index).
Connections to large deviations theory
Sanov's theorem in the IT formulation is equivalent to Cramer's theorem 37.07.02 for the empirical mean, but stated in the stronger topology of distributions rather than means. The contraction principle in large deviations theory says that if satisfies a large deviation principle with rate function , then the image satisfies a large deviation principle with rate function .
This contraction principle directly yields Cramer's theorem: the empirical mean is a function of the type, and the rate function for is , which by Lagrangian duality equals the Legendre transform of the cumulant generating function.
The I-projection and Sanov's theorem for convex sets
When is convex, the minimiser is unique and is called the I-projection of onto . The I-projection satisfies a Pythagorean identity: for any ,
This identity is the foundation of iterative proportional fitting (IPF) and the iterative algorithms for computing maximum-entropy distributions subject to linear constraints.
Synthesis. The method of types collapses exponential-sized sequence spaces into polynomial-sized type classes, with type-class size governed by entropy; Sanov's theorem identifies KL divergence as the rate function for large deviations of the empirical distribution. The central insight builds toward universal source coding where the type-class size bound directly controls the overhead of codes that achieve entropy without knowing the distribution. This is exactly the bridge between combinatorics and probability that makes information theory cohere: entropy counts sequences, KL divergence measures how unlikely a type is, and the polynomial number of types makes the counting tractable. The method of types generalises to conditional types and the I-projection, appears again in 46.04.01 as the engine behind the Stein lemma, and putting these together yields a unified combinatorial framework for all of large-deviation information theory.
Full proof set Master
Proposition (Type class size bounds). For any -type on an alphabet of size :
Proof. The size of the type class is the multinomial coefficient .
Upper bound. By the entropy bound on multinomial coefficients:
Lower bound. By Stirling's approximation, for . More precisely, . Applying to each factorial:
where is a constant absorbed into the polynomial correction.
Connections Master
37.07.02— Cramer's theorem is the large-deviation result for empirical means; Sanov's theorem is the stronger result for empirical distributions, and Cramer's theorem follows by contraction.46.02.01— The AEP identifies the typical set; the method of types refines this by partitioning sequences into type classes, each of size .46.01.02— KL divergence is both the rate function in Sanov's theorem and the measure of divergence between distributions; this dual role is the central theme.46.02.03— Huffman coding achieves entropy for known distributions; universal codes based on types achieve entropy for unknown distributions with vanishing overhead.46.04.01— The Stein lemma in hypothesis testing uses Sanov's theorem to identify the optimal error exponent as the KL divergence.
Historical & philosophical context Master
The method of types was developed by Imre Csiszar in a series of papers spanning the 1970s-1990s, culminating in his 1998 survey "The Method of Types" (IEEE Trans. Info. Theory 44(6), pp. 2505-2523). Csiszar's insight was that many results in information theory — Sanov's theorem, universal coding, hypothesis testing — could be derived purely combinatorially by counting type classes, without invoking measure theory or stochastic processes.
Sanov's theorem itself was proved by I. N. Sanov in 1957 ("On the probability of large deviations of random variables," Mat. Sbornik 42, pp. 11-44). The original proof used the change-of-measure technique from large deviations theory. Csiszar's combinatorial proof via the method of types is more elementary and more aligned with the information-theoretic perspective.
The connection between Sanov's theorem and Cramer's theorem (1938) was clarified by the contraction principle in large deviations theory, developed by Varadhan in the 1960s-1970s. The contraction principle shows that Sanov's theorem is the "master" result from which Cramer's theorem follows as a corollary, placing the method of types at the foundation of the large deviations hierarchy.
Bibliography Master
@article{sanov1957,
author = {Sanov, I. N.},
title = {On the Probability of Large Deviations of Random Variables},
journal = {Matematicheskii Sbornik},
volume = {42},
pages = {11--44},
year = {1957},
}
@article{csiszar1998,
author = {Csisz{\'a}r, I.},
title = {The Method of Types},
journal = {IEEE Transactions on Information Theory},
volume = {44},
number = {6},
pages = {2505--2523},
year = {1998},
}
@book{dembo-zeitouni1998,
author = {Dembo, A. and Zeitouni, O.},
title = {Large Deviations Techniques and Applications},
edition = {2nd},
publisher = {Springer},
year = {1998},
}
@book{cover-thomas2006,
author = {Cover, T. M. and Thomas, J. A.},
title = {Elements of Information Theory},
edition = {2nd},
publisher = {Wiley},
year = {2006},
}