Conditional entropy (Definition 10.2.1)
DefinitionWildeQIT_condEntropyDefinition 10.2.1 (Conditional entropy). Let and be discrete random variables with joint probability distribution on the finite alphabet . The conditional entropy is the expected conditional information content, where the expectation is with respect to both and :
where is the marginal of and is the conditional distribution of given . The logarithm is base .
The conditional entropy measures the uncertainty that remains about once is known. It is the building block of the joint entropy chain rule and of the mutual information .
Formalization Note. WildeQIT.condEntropy p, for p : WildeQIT.FinDist (α × β) the joint distribution of the pair , is the last expression above: . It is the entropy of the first component conditioned on the second; is obtained by applying it to the swapped joint distribution p.swap. When the term vanishes (convention , automatic since Real.logb 2 0 = 0); when every with that is zero as well, so the real-division convention never affects the value.
import Definitions.Def_WildeQIT_FinDist
import Mathlib.Analysis.SpecialFunctions.Log.Base
/-!
Wilde, *Quantum Information Theory* (2nd ed.), Definition 10.2.1 (Conditional entropy):
for discrete random variables `X, Y` with joint distribution `p_{XY}`,
`H(X|Y) ≡ -∑_{x,y} p_{XY}(x,y) log p_{X|Y}(x|y)`, where `p_{X|Y}(x|y) = p_{XY}(x,y)/p_Y(y)`.
-/
namespace WildeQIT
/-- Definition 10.2.1. The conditional entropy `H(X|Y)` of the first component given the
second, for a joint distribution `p` on `α × β`:
`H(X|Y) = -∑_{x,y} p(x,y) log₂ ( p(x,y) / p_Y(y) )`, in bits.
A term with `p(x,y) = 0` contributes `0` (convention `0 log 0 = 0`); when `p_Y(y) = 0`
every `p(x,y)` with that `y` vanishes, so the (junk) quotient `p(x,y)/0` never contributes. -/
noncomputable def condEntropy {α β : Type} [Fintype α] [Fintype β] (p : FinDist (α × β)) : ℝ :=
-∑ x, ∑ y, p.prob (x, y) * Real.logb 2 (p.prob (x, y) / p.snd.prob y)
end WildeQIT