KL Divergence and Finite PMFs #
Pure mathematical infrastructure for probability mass functions over finite types, KL divergence, cross-entropy, and expected values. No learning-theory types.
Main definitions #
FinitePMF: a probability mass function over a finite typeklDivFinitePMF: KL divergence between two FinitePMFscrossEntropyFinitePMF: cross-entropy H(Q, P)expectFinitePMF: expected value E_{h~Q}[f(h)]HasPositivePrior: typeclass for PMFs with strictly positive weights
References #
- Cover & Thomas, "Elements of Information Theory", Chapter 2
KL divergence between two FinitePMFs over a finite type. KL(Q‖P) = ∑_h Q(h) · log(Q(h)/P(h)). Convention: 0 · log(0/p) = 0.
Equations
Instances For
Cross-entropy: ∑_h Q(h) · log(1/P(h)). Equals KL(Q‖P) + H(Q) where H(Q) is Shannon entropy.