Entropy of a random variable (Definition 10.1.1)
DefinitionWildeQIT_entropyDefinition 10.1.1 (Entropy). The entropy of a discrete random variable with probability distribution on a finite alphabet is
with the logarithm taken base (so that entropy is measured in bits), and with the convention for letters of probability zero.
Entropy quantifies the surprise, or information content, of a random variable on average: is the expected value of the information content of the outcome . It is the central quantity of classical information theory and every other quantity of Wilde's Chapter 10 (conditional entropy, joint entropy, mutual information, relative entropy) is built from it.
Formalization Note. WildeQIT.entropy p is as a real number, for p : WildeQIT.FinDist α a probability distribution on a finite alphabet α. The logarithm is Real.logb 2. The convention is automatic, because Mathlib defines Real.logb 2 0 = 0, so a letter with contributes to the sum.
import Definitions.Def_WildeQIT_FinDist
import Mathlib.Analysis.SpecialFunctions.Log.Base
/-!
Wilde, *Quantum Information Theory* (2nd ed.), Definition 10.1.1 (Entropy):
`H(X) ≡ -∑_x p_X(x) log p_X(x)`, logarithm base 2 (bits), with the convention `0 log 0 = 0`.
-/
namespace WildeQIT
/-- Definition 10.1.1. The (Shannon) entropy of a random variable with distribution `p`,
in bits: `H(X) = -∑_x p(x) log₂ p(x)`. The convention `0 log 0 = 0` holds automatically,
because `Real.logb 2 0 = 0`. -/
noncomputable def entropy {α : Type} [Fintype α] (p : FinDist α) : ℝ :=
-∑ x, p.prob x * Real.logb 2 (p.prob x)
end WildeQIT