Binary KL divergence and its boundary values #
klBin p q = p·log(p/q) + (1 − p)·log((1 − p)/(1 − q)), the KL divergence
between Bernoulli(p) and Bernoulli(q). Well-defined for q ∈ (0, 1);
the boundary values at p = 0, p = 1, and p = q reduce to explicit
log-terms via the conventional log 0 = 0.
theorem
InformationTheory.klBin_expand
(p q : ℝ)
(hp₀ : 0 < p)
(hp₁ : p < 1)
(hq₀ : 0 < q)
(hq₁ : q < 1)
:
Expanded form: split into constants and q-dependent pieces. Used to compute the
derivative via HasDerivAt in the next shard.