Kullback–Leibler divergence of finite distributions #
The library has one divergence notion, Mathlib's InformationTheory.klDiv, and one entropy
notion, Cslib.Probability.PMF.entropy. This file bridges them. For PMFs on a finite type with
a discrete measurable structure, klDiv p.toMeasure q.toMeasure is finite exactly when the
support of p is contained in that of q, and is then the finite sum
∑ a, p a * log (p a / q a) in nats. Consequences:
- Gibbs' inequality: the sum is nonnegative and vanishes only at
p = q. Equivalently, the entropy ofpis at most its cross-entropy∑ a, p a * surprisal q a. - Entropy is the logarithm of the alphabet size minus the divergence from uniform.
- Mutual information,
H(X) + H(Y) - H(X, Y), is the divergence of the joint law from the product of its marginals. Entropy is subadditive and conditioning cannot increase it; by the equality case of Gibbs' inequality, subadditivity is an equality exactly for independent pairs. - Pinsker's inequality
2 δ(p, q)² ≤ D(p ‖ q)for the statistical distanceδ, from the form for arbitrary probability measures and events inProbability/Pinsker. Statistical distance is half of Mathlib's total variation distancetvDist.
Divergences are in nats and entropies in bits, so the bridges divide by log 2.
Main results #
Cslib.Probability.PMF.toReal_klDiv_toMeasure: the finite-sum formula.Cslib.Probability.PMF.klDiv_toMeasure_ne_top_iff: finiteness is support inclusion.Cslib.Probability.PMF.klDiv_toMeasure_map_le: data processing for deterministic maps.Cslib.Probability.PMF.sum_mul_log_div_nonneg,.sum_mul_log_div_eq_zero_iff: Gibbs.Cslib.Probability.PMF.entropy_le_sum_mul_surprisal: entropy is at most cross-entropy.Cslib.Probability.PMF.entropy_le_logb_card_of_support_subset: entropy is at most the logarithm of the support size.Cslib.Probability.PMF.entropy_eq_logb_card_sub_klDiv: entropy and divergence from uniform.Cslib.Probability.PMF.entropy_map_fst_add_entropy_map_snd_sub_entropy: mutual information.Cslib.Probability.PMF.entropy_le_entropy_map_fst_add_entropy_map_snd: subadditivity, with equality exactly for independent pairs (Cslib.Probability.PMF.entropy_eq_entropy_map_fst_add_entropy_map_snd_iff).Cslib.Probability.PMF.conditionalEntropy_le_entropy_map_snd: conditioning reduces entropy.Cslib.Probability.PMF.ofReal_two_mul_dist_sq_le_klDiv,Cslib.Probability.PMF.dist_le_sqrt_toReal_klDiv_div_two: Pinsker's inequality.
References #
- T. M. Cover, J. A. Thomas, Elements of Information Theory, Theorems 2.6.3 (Gibbs), 2.6.4 (uniform maximizes entropy), 2.6.5 (conditioning reduces entropy), 2.6.6 (independence bound on entropy, here for two variables), Section 2.3 and Theorem 2.4.1 (mutual information) and Lemma 11.6.1 (Pinsker).
The finite-sum formula #
A PMF measure on a countable type is absolutely continuous with respect to another exactly when its support is contained in the other's support.
The finite-sum formula for the Kullback–Leibler divergence of finite distributions, in
nats. Null outcomes of p contribute zero.
The divergence of finite distributions is finite exactly when the support of the first is contained in the support of the second.
The divergence of finite distributions with nested supports, as an extended real.
Data processing: a deterministic map cannot increase the divergence of distributions on a countable type.
Gibbs' inequality #
Entropy is the logarithm of the alphabet size minus the divergence from the uniform distribution, converted to bits.
Mutual information and subadditivity #
Mutual information I(X; Y) = H(X) + H(Y) - H(X, Y), in bits, is the divergence of
the joint law from the product of its marginals.
Pinsker's inequality #
Pinsker's inequality for finite distributions: twice the squared statistical distance is at most the Kullback–Leibler divergence, in nats.
Pinsker's inequality in its usual form: statistical distance is at most
sqrt (D(p ‖ q) / 2), the divergence in nats.