Documentation

CslibFrontier.Probability.BinaryKL

Binary relative entropy #

The binary relative entropy binaryKL q p = q log (q / p) + (1 - q) log ((1 - q) / (1 - p)) of Bernoulli parameters q, p ∈ [0, 1], in nats, written with Mathlib's klFun as p klFun (q / p) + (1 - p) klFun ((1 - q) / (1 - p)).

At p ∈ {0, 1} with q ≠ p the true divergence is infinite; binaryKL takes finite junk values there, so Jensen's inequality is stated for pairs with q = p wherever p ∈ {0, 1}.

Main definitions #

Main results #

References #

noncomputable def Cslib.Probability.binaryKL (q p : ℝ) :

The binary relative entropy q log (q / p) + (1 - q) log ((1 - q) / (1 - p)) of Bernoulli parameters, in nats.

theorem Cslib.Probability.binaryKL_nonneg {q p : ℝ} (hq : q ∈ Set.Icc 0 1) (hp : p ∈ Set.Icc 0 1) :

For fixed p, binaryKL · p is continuous.

theorem Cslib.Probability.binaryKL_eq_mul_log {q p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) :
binaryKL q p = q * Real.log (q / p) + (1 - q) * Real.log ((1 - q) / (1 - p))

For p ∈ (0, 1), binaryKL q p = q log (q / p) + (1 - q) log ((1 - q) / (1 - p)).

theorem Cslib.Probability.choose_mul_pow_mul_exp_binaryKL_le_one {p : ℝ} (hp : p ∈ Set.Icc 0 1) {m k : ℕ} (hk : k ≤ m) :
↑(m.choose k) * p ^ k * (1 - p) ^ (m - k) * Real.exp (↑m * binaryKL (↑k / ↑m) p) ≤ 1

A binomial probability is at most exp (-m binaryKL (k / m) p): C(m, k) p ^ k (1 - p) ^ (m - k) exp (m binaryKL (k / m) p) ≤ 1 for p ∈ [0, 1] and k ≤ m. The left side is the probability of k successes in m trials of success probability k / m.

theorem Cslib.Probability.convexOn_binaryKL {p : ℝ} (hp : p ∈ Set.Icc 0 1) :
ConvexOn ℝ (Set.Icc 0 1) fun (q : ℝ) => binaryKL q p

For fixed p ∈ [0, 1], the binary relative entropy is convex in its first argument.

theorem Cslib.Probability.convexOn_exp_mul_binaryKL {p t : ℝ} (hp : p ∈ Set.Icc 0 1) (ht : 0 ≤ t) :
ConvexOn ℝ (Set.Icc 0 1) fun (q : ℝ) => Real.exp (t * binaryKL q p)

For fixed p ∈ [0, 1] and t ≥ 0, exp (t binaryKL · p) is convex on [0, 1].

theorem Cslib.Probability.mul_klFun_integral_div_integral_le {α : Type u_1} {mα : MeasurableSpace α} {μ : MeasureTheory.Measure α} {a b : α → ℝ} (ha : ∀ (x : α), 0 ≤ a x) (hb : ∀ (x : α), 0 ≤ b x) (hab : ∀ (x : α), b x = 0 → a x = 0) (hai : MeasureTheory.Integrable a μ) (hbi : MeasureTheory.Integrable b μ) (hi : MeasureTheory.Integrable (fun (x : α) => b x * InformationTheory.klFun (a x / b x)) μ) :
(∫ (x : α), b x ∂μ) * InformationTheory.klFun ((∫ (x : α), a x ∂μ) / ∫ (x : α), b x ∂μ) ≤ ∫ (x : α), b x * InformationTheory.klFun (a x / b x) ∂μ

The log-sum inequality [CoverThomas2006, Theorem 2.7.1] in integral form: Jensen for the perspective of klFun: for nonnegative integrable a and b with a = 0 wherever b = 0, (∫ b) klFun ((∫ a) / ∫ b) ≤ ∫ b klFun (a / b).

theorem Cslib.Probability.binaryKL_integral_le_integral {α : Type u_1} {mα : MeasurableSpace α} {μ : MeasureTheory.Measure α} [MeasureTheory.IsProbabilityMeasure μ] {q p : α → ℝ} (hq : ∀ (x : α), q x ∈ Set.Icc 0 1) (hp : ∀ (x : α), p x ∈ Set.Icc 0 1) (h0 : ∀ (x : α), p x = 0 → q x = 0) (h1 : ∀ (x : α), p x = 1 → q x = 1) (hqm : AEMeasurable q μ) (hpm : AEMeasurable p μ) (hkl : MeasureTheory.Integrable (fun (x : α) => binaryKL (q x) (p x)) μ) :
binaryKL (∫ (x : α), q x ∂μ) (∫ (x : α), p x ∂μ) ≤ ∫ (x : α), binaryKL (q x) (p x) ∂μ

Jensen's inequality for the binary relative entropy: for q, p with values in [0, 1] under a probability measure, with q = 0 wherever p = 0 and q = 1 wherever p = 1, binaryKL (∫ q) (∫ p) ≤ ∫ binaryKL q p. Without the conditions on p = 0 and p = 1, where the true divergence is infinite unless q = p, the junk values of binaryKL are not convex.

theorem Cslib.Probability.two_mul_sq_le_binaryKL {q p : ℝ} (hq : q ∈ Set.Icc 0 1) (hp0 : 0 < p) (hp1 : p < 1) :
2 * (q - p) ^ 2 ≤ binaryKL q p

Bernoulli Pinsker's inequality: for q ∈ [0, 1] and p ∈ (0, 1), 2 * (q - p) ^ 2 ≤ binaryKL q p.

theorem Cslib.Probability.sub_sq_div_two_mul_le_binaryKL {q p : ℝ} (hq0 : 0 ≤ q) (hqp : q ≤ p) (hp0 : 0 < p) (hp1 : p < 1) :
(p - q) ^ 2 / (2 * p) ≤ binaryKL q p

Quadratic empirical-Bernstein lower bound on binaryKL: for 0 ≤ q ≤ p < 1 (0 < p), (p - q) ^ 2 / (2 * p) ≤ binaryKL q p. Sharp for small q (O(p) at q = 0), yielding the fast-rate PAC-Bayes inversion [TS13] (locator unverified).

theorem Cslib.Probability.abs_sub_le_sqrt_of_binaryKL_le {q p c : ℝ} (hq : q ∈ Set.Icc 0 1) (hp0 : 0 < p) (hp1 : p < 1) (hle : binaryKL q p ≤ c) :
|p - q| ≤ √(c / 2)

Exact Pinsker inversion: for q ∈ [0, 1] and p ∈ (0, 1), binaryKL q p ≤ c implies |p - q| ≤ √(c / 2).

theorem Cslib.Probability.le_add_add_sqrt_of_binaryKL_le {q p c : ℝ} (hq0 : 0 ≤ q) (hp1 : p < 1) (hc : 0 ≤ c) (hle : binaryKL q p ≤ c) :
p ≤ q + c + √(c ^ 2 + 2 * q * c)

Sharp quadratic inversion of binaryKL q p ≤ c: for 0 ≤ q, p < 1, and 0 ≤ c, p ≤ q + c + √(c ^ 2 + 2 * q * c).

theorem Cslib.Probability.le_add_sqrt_two_mul_add_two_mul_of_binaryKL_le {q p c : ℝ} (hq0 : 0 ≤ q) (hp1 : p < 1) (hc : 0 ≤ c) (hle : binaryKL q p ≤ c) :
p ≤ q + √(2 * q * c) + 2 * c

Standard relaxed fast-rate inversion [TS13] (locator unverified): binaryKL q p ≤ c ⟹ p ≤ q + √(2 * q * c) + 2 * c.

theorem Cslib.Probability.le_one_sub_exp_neg_of_binaryKL_zero_le {p c : ℝ} (hp0 : 0 ≤ p) (hp1 : p < 1) (hle : binaryKL 0 p ≤ c) :
p ≤ 1 - Real.exp (-c)

Zero-empirical-risk inversion: for p ∈ [0, 1), binaryKL 0 p ≤ c gives p ≤ 1 - exp (-c) (and hence p ≤ c).