Documentation

CslibFrontier.Probability.MutualInformation

Mutual information and conditional mutual information #

For a joint law of two finite random variables, the mutual information I(A; B) = H(A) + H(B) - H(A, B) (mutualInfo) measures how much one reveals about the other, in bits. For a joint law of three, listed with the conditioning variable first, the conditional mutual information I(A; B | C) = H(C, A) + H(C, B) - H(C, A, B) - H(C) (condMutualInfo) measures the same given C Cover and Thomas, Sections 2.4 and 2.5. Both are nonnegative: the first is subadditivity of entropy, the second says conditioning on more cannot increase entropy.

Random variables are usually functions of an outcome drawn from ν : PMF Ω, and the lemmas take the form mutualInfo (ν.map fun ω => (A ω, B ω)). In this form:

Main definitions #

Main results #

Implementation notes #

The entropy chain rule entropy_map_prodMk_eq_add_sum and the conditioning lemmas map_fst_map_prodMk, conditionalSnd_map_prodMk_apply and eq_of_mem_support_conditionalSnd_map do not mention mutual information. They live here because the chain rules are their only clients so far; they could move to Probability.Entropy and Probability.Conditioning when other modules need them.

References #

noncomputable def Cslib.Probability.PMF.mutualInfo {α : Type u_1} {β : Type u_2} [Finite α] [Finite β] (joint : PMF (α × β)) :

The mutual information I(A; B) = H(A) + H(B) - H(A, B) of a joint law, in bits.

noncomputable def Cslib.Probability.PMF.condMutualInfo {α : Type u_1} {β : Type u_2} {γ : Type u_3} [Finite γ] [Finite α] [Finite β] (joint : PMF (γ × α × β)) :

The conditional mutual information I(A; B | C) = H(C, A) + H(C, B) - H(C, A, B) - H(C) of a joint law of (C, A, B), in bits.

theorem Cslib.Probability.PMF.mutualInfo_nonneg {α : Type u_1} {β : Type u_2} [Finite α] [Finite β] (joint : PMF (α × β)) :
0 ≤ mutualInfo joint

I(A; B) = H(B) - H(B | A): the mutual information is the entropy of B that A removes.

theorem Cslib.Probability.PMF.mutualInfo_le_entropy_map_snd {α : Type u_1} {β : Type u_2} [Finite α] [Finite β] (joint : PMF (α × β)) :
theorem Cslib.Probability.PMF.mutualInfo_eq_zero_iff {α : Type u_1} {β : Type u_2} [Finite α] [Finite β] (joint : PMF (α × β)) :
mutualInfo joint = 0 ↔ joint = (PMF.map Prod.fst joint).bind fun (a : α) => PMF.map (fun (x : β) => (a, x)) (PMF.map Prod.snd joint)

The mutual information vanishes exactly for independent pairs, whose joint law is the product of its marginals.

theorem Cslib.Probability.PMF.entropy_map_eq_of_comp {α : Type u_1} {β : Type u_2} {Ω : Type u_7} [Finite α] [Finite β] (ν : PMF Ω) {F : Ω → α} {G : Ω → β} {e : α → β} (he : Function.Injective e) (h : ∀ ω ∈ ν.support, G ω = e (F ω)) :

Entropy does not see an injective re-encoding G = e ∘ F that holds on the support.

theorem Cslib.Probability.PMF.mutualInfo_map {α : Type u_1} {β : Type u_2} {Ω : Type u_7} [Finite α] [Finite β] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) :
mutualInfo (PMF.map (fun (ω : Ω) => (A ω, B ω)) ν) = entropy (PMF.map A ν) + entropy (PMF.map B ν) - entropy (PMF.map (fun (ω : Ω) => (A ω, B ω)) ν)
theorem Cslib.Probability.PMF.condMutualInfo_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {Ω : Type u_7} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (B : Ω → β) :
condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) = entropy (PMF.map (fun (ω : Ω) => (C ω, A ω)) ν) + entropy (PMF.map (fun (ω : Ω) => (C ω, B ω)) ν) - entropy (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) - entropy (PMF.map C ν)
theorem Cslib.Probability.PMF.condMutualInfo_nonneg {α : Type u_1} {β : Type u_2} {γ : Type u_3} [Finite γ] [Finite α] [Finite β] (joint : PMF (γ × α × β)) :

Conditional mutual information is nonnegative: conditioning on A as well as C cannot increase the entropy of B.

theorem Cslib.Probability.PMF.condMutualInfo_le_conditionalEntropy_fst {α : Type u_1} {β : Type u_2} {γ : Type u_3} [Finite γ] [Finite α] [Finite β] (joint : PMF (γ × α × β)) :

I(A; B | C) ≤ H(A | C).

theorem Cslib.Probability.PMF.condMutualInfo_le_conditionalEntropy_snd {α : Type u_1} {β : Type u_2} {γ : Type u_3} [Finite γ] [Finite α] [Finite β] (joint : PMF (γ × α × β)) :

I(A; B | C) ≤ H(B | C).

theorem Cslib.Probability.PMF.entropy_map_prodMk_eq_add_sum {α : Type u_1} {γ : Type u_3} {Ω : Type u_7} [Fintype γ] [Finite α] (ν : PMF Ω) (B : Ω → γ) (F : Ω → α) :
entropy (PMF.map (fun (ω : Ω) => (B ω, F ω)) ν) = entropy (PMF.map B ν) + ∑ c : γ, ((PMF.map B ν) c).toReal * entropy (PMF.map F (conditionalSnd (PMF.map (fun (ω : Ω) => (B ω, ω)) ν) c))

Revealing B, the joint entropy of (B, F) splits into that of B and the average entropy of F given each value of B.

theorem Cslib.Probability.PMF.condMutualInfo_eq_zero_of_apply_eq_mul {α : Type u_1} {β : Type u_2} {γ : Type u_3} [Finite γ] [Finite α] [Finite β] (joint : PMF (γ × α × β)) (f : γ → α → ENNReal) (g : γ → β → ENNReal) (h : ∀ (c : γ) (a : α) (b : β), joint (c, a, b) = f c a * g c b) :

I(A; B | C) = 0 when the joint law of (C, A, B) factors as f (c, a) * g (c, b): given C, the variables A and B are independent.

theorem Cslib.Probability.PMF.condMutualInfo_map_eq_zero_of_determined {α : Type u_1} {β : Type u_2} {γ : Type u_3} {Ω : Type u_7} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (T : Ω → β) (k : γ → β) (h : ∀ ω ∈ ν.support, T ω = k (C ω)) :
condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, T ω)) ν) = 0

If T is determined by C on the support, it carries no information about A given C.

theorem Cslib.Probability.PMF.condMutualInfo_map_congr {α : Type u_1} {γ : Type u_3} {τ : Type u_5} {τ' : Type u_6} {Ω : Type u_7} [Finite γ] [Finite α] [Finite τ] [Finite τ'] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) {T : Ω → τ} {T' : Ω → τ'} {e : τ → τ'} (he : Function.Injective e) (h : ∀ ω ∈ ν.support, T' ω = e (T ω)) :
condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, T' ω)) ν) = condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, T ω)) ν)

Injective re-encoding of the last variable on the support does not change conditional mutual information.

theorem Cslib.Probability.PMF.mutualInfo_map_congr {α : Type u_1} {τ : Type u_5} {τ' : Type u_6} {Ω : Type u_7} [Finite α] [Finite τ] [Finite τ'] (ν : PMF Ω) (A : Ω → α) {T : Ω → τ} {T' : Ω → τ'} {e : τ → τ'} (he : Function.Injective e) (h : ∀ ω ∈ ν.support, T' ω = e (T ω)) :
mutualInfo (PMF.map (fun (ω : Ω) => (A ω, T' ω)) ν) = mutualInfo (PMF.map (fun (ω : Ω) => (A ω, T ω)) ν)

Injective re-encoding of the second variable on the support does not change mutual information.

theorem Cslib.Probability.PMF.mutualInfo_map_swap_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} {Ω : Type u_7} [Finite α] [Finite β] [Finite γ] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (T : Ω → γ) :
mutualInfo (PMF.map (fun (ω : Ω) => ((B ω, A ω), T ω)) ν) = mutualInfo (PMF.map (fun (ω : Ω) => ((A ω, B ω), T ω)) ν)

Swapping the two parts of the first variable does not change mutual information.

theorem Cslib.Probability.PMF.mutualInfo_map_prodMk_eq_add {α : Type u_1} {β : Type u_2} {γ : Type u_3} {Ω : Type u_7} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (B : Ω → β) :
mutualInfo (PMF.map (fun (ω : Ω) => ((C ω, A ω), B ω)) ν) = mutualInfo (PMF.map (fun (ω : Ω) => (C ω, B ω)) ν) + condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν)

Chain rule: I((C, A); B) = I(C; B) + I(A; B | C).

theorem Cslib.Probability.PMF.condMutualInfo_map_le_mutualInfo {α : Type u_1} {β : Type u_2} {γ : Type u_3} {Ω : Type u_7} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (B : Ω → β) :
condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) ≤ mutualInfo (PMF.map (fun (ω : Ω) => ((C ω, A ω), B ω)) ν)

I(A; B | C) ≤ I((C, A); B).

theorem Cslib.Probability.PMF.mutualInfo_map_eq_add_sum {α : Type u_1} {δ : Type u_4} {τ : Type u_5} {Ω : Type u_7} [Fintype δ] [Finite α] [Finite τ] (ν : PMF Ω) (A : Ω → α) (T : Ω → τ) (B : Ω → δ) (k : τ → δ) (hB : ∀ (ω : Ω), B ω = k (T ω)) :
mutualInfo (PMF.map (fun (ω : Ω) => (A ω, T ω)) ν) = mutualInfo (PMF.map (fun (ω : Ω) => (A ω, B ω)) ν) + ∑ b : δ, ((PMF.map B ν) b).toReal * mutualInfo (PMF.map (fun (ω : Ω) => (A ω, T ω)) (conditionalSnd (PMF.map (fun (ω : Ω) => (B ω, ω)) ν) b))

Chain rule for I(A; T) through an observation B = k ∘ T: I(A; T) = I(A; B) + E_b I(A; T | B = b).

theorem Cslib.Probability.PMF.condMutualInfo_map_eq_add_sum {α : Type u_1} {γ : Type u_3} {δ : Type u_4} {τ : Type u_5} {Ω : Type u_7} [Fintype δ] [Finite γ] [Finite α] [Finite τ] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (T : Ω → τ) (B : Ω → δ) (k : τ → δ) (hB : ∀ (ω : Ω), B ω = k (T ω)) :
condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, T ω)) ν) = condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) + ∑ b : δ, ((PMF.map B ν) b).toReal * condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, T ω)) (conditionalSnd (PMF.map (fun (ω : Ω) => (B ω, ω)) ν) b))

Chain rule through an observation B = k ∘ T: I(A; T | C) = I(A; B | C) + E_b I(A; T | C, B = b).

theorem Cslib.Probability.PMF.mutualInfo_bind_map_prodMk {α : Type u_1} {β : Type u_2} [Finite α] [Finite β] (p : PMF α) (q : PMF β) :
mutualInfo (p.bind fun (a : α) => PMF.map (fun (x : β) => (a, x)) q) = 0

Independent components carry no mutual information.

Conditioning on an observation #

theorem Cslib.Probability.PMF.map_fst_map_prodMk {β : Type u_2} {Ω : Type u_7} (ν : PMF Ω) (f : Ω → β) :
PMF.map Prod.fst (PMF.map (fun (ω : Ω) => (f ω, ω)) ν) = PMF.map f ν
theorem Cslib.Probability.PMF.eq_of_mem_support_conditionalSnd_map {β : Type u_2} {Ω : Type u_7} (ν : PMF Ω) (f : Ω → β) {c : β} (hc : (PMF.map f ν) c ≠ 0) {ω : Ω} (hω : ω ∈ (conditionalSnd (PMF.map (fun (ω : Ω) => (f ω, ω)) ν) c).support) :
f ω = c

Conditioning on f = c keeps only outcomes with f ω = c.

theorem Cslib.Probability.PMF.conditionalSnd_map_prodMk_apply {β : Type u_2} {Ω : Type u_7} [DecidableEq β] (ν : PMF Ω) (f : Ω → β) {c : β} (hc : (PMF.map f ν) c ≠ 0) (ω : Ω) :
(conditionalSnd (PMF.map (fun (ω : Ω) => (f ω, ω)) ν) c) ω = (if f ω = c then ν ω else 0) / (PMF.map f ν) c

Conditioning on f = c restricts to f ω = c and renormalizes.