Bandits.ClippedUCB.sum_ucb_sub_mean_le
This page has the declaration's own card below, then its dependency graph, then a card for each dependency (type dependencies first, then the rest of the transitive closure). For a theorem, the graph and the dependency cards only follow its statement's dependencies (its proof is replaced by sorry, so what it proves doesn't depend on how); for everything else, both the type and the body/value are followed, since their content is part of what later declarations build on.
sum_ucb_sub_mean_le๐
Bandits.ClippedUCB.sum_ucb_sub_mean_leNo docstring.
Bandits.ClippedUCB.sum_ucb_sub_mean_le.{u_1} {K : โ} {l u ฯ2 ฮด : โ} {ฮฉ : Type u_1} {A : โ โ ฮฉ โ Fin K} {R : โ โ ฮฉ โ โ} {n : โ} {ฯ : ฮฉ} (ฮผ : Fin K โ โ) (hฮผ : โ (a : Fin K), ฮผ a โ Set.Icc l u) (hi : l โค u) (hc : โ s < n, Learning.pullCount A (A s ฯ) s ฯ โ 0 โ Learning.empMean A R (A s ฯ) s ฯ - ฮผ (A s ฯ) < โ(2 * ฯ2 * Real.log (1 / ฮด) / โ(Learning.pullCount A (A s ฯ) s ฯ))) : โ s โ Finset.range n, (ucb A R l u ฯ2 ฮด (A s ฯ) s ฯ - ฮผ (A s ฯ)) โค (u - l) * โK + 4 * โ(2 * ฯ2 * Real.log (1 / ฮด) * โK * โn)Bandits.ClippedUCB.sum_ucb_sub_mean_le.{u_1} {K : โ} {l u ฯ2 ฮด : โ} {ฮฉ : Type u_1} {A : โ โ ฮฉ โ Fin K} {R : โ โ ฮฉ โ โ} {n : โ} {ฯ : ฮฉ} (ฮผ : Fin K โ โ) (hฮผ : โ (a : Fin K), ฮผ a โ Set.Icc l u) (hi : l โค u) (hc : โ s < n, Learning.pullCount A (A s ฯ) s ฯ โ 0 โ Learning.empMean A R (A s ฯ) s ฯ - ฮผ (A s ฯ) < โ(2 * ฯ2 * Real.log (1 / ฮด) / โ(Learning.pullCount A (A s ฯ) s ฯ))) : โ s โ Finset.range n, (ucb A R l u ฯ2 ฮด (A s ฯ) s ฯ - ฮผ (A s ฯ)) โค (u - l) * โK + 4 * โ(2 * ฯ2 * Real.log (1 / ฮด) * โK * โn)
Code
lemma sum_ucb_sub_mean_le {n : โ} {ฯ : ฮฉ} (ฮผ : Fin K โ โ) (hฮผ : โ a, ฮผ a โ Set.Icc l u) (hi : l โค u)
(hc : โ s < n, pullCount A (A s ฯ) s ฯ โ 0 โ empMean A R (A s ฯ) s ฯ - ฮผ (A s ฯ)
< โ(2 * ฯ2 * Real.log (1 / ฮด) / (pullCount A (A s ฯ) s ฯ))) :
โ s โ range n, (ucb A R l u ฯ2 ฮด (A s ฯ) s ฯ - ฮผ (A s ฯ))
โค (u - l) * K + 4 * โ(2 * ฯ2 * Real.log (1 / ฮด) * K * n)Body uses (3)
Actions: Source ยท Open Issue
Proof
by
let Sโ := {s โ range n | pullCount A (A s ฯ) s ฯ = 0}
let Sโ := {s โ range n | pullCount A (A s ฯ) s ฯ โ 0}
have hu : Sโ โช Sโ = range n := filter_union_filter_not_eq _ _
have hd : Disjoint Sโ Sโ := disjoint_filter_filter_not _ _ _
rw [โ hu, sum_union hd]
gcongr
ยท calc โ s โ Sโ, (ucb A R l u ฯ2 ฮด (A s ฯ) s ฯ - ฮผ (A s ฯ))
โค โ s โ Sโ, (u - l) :=
have (s : โ) : ucb A R l u ฯ2 ฮด (A s ฯ) s ฯ โ Set.Icc l u := ucb_mem_Icc hi
sum_le_sum (by grind)
_ = โ s โ range n, if pullCount A (A s ฯ) s ฯ = 0 then (u - l) else 0 := by
rw [sum_filter]
_ = โ a, โ j โ range (pullCount A a n ฯ), if j = 0 then (u - l) else 0 :=
sum_comp_pullCount (fun j => if j = 0 then (u - l) else 0) n ฯ
_ โค โ a, (u - l) := by
gcongr
rw [sum_ite_eq']
grind
_ = (u - l) * K := by
rw [Fin.sum_const, nsmul_eq_mul, mul_comm]
ยท calc โ s โ Sโ, (ucb A R l u ฯ2 ฮด (A s ฯ) s ฯ - ฮผ (A s ฯ))
โค โ s โ Sโ, 2 * โ(2 * ฯ2 * Real.log (1 / ฮด) / (pullCount A (A s ฯ) s ฯ)) := by
gcongr with s hs
unfold ucb
have : 0 โค โ(2 * ฯ2 * Real.log (1 / ฮด) / (pullCount A (A s ฯ) s ฯ)) := by positivity
grind
_ โค โ s โ range n, 2 * โ(2 * ฯ2 * Real.log (1 / ฮด) / (pullCount A (A s ฯ) s ฯ)) :=
sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (fun _ _ _ => by positivity)
_ = 2 * โ(2 * ฯ2 * Real.log (1 / ฮด)) * โ s โ range n, (1 / โ(pullCount A (A s ฯ) s ฯ)) := by
rw [mul_sum]
congr with s
rw [Real.sqrt_div' _ (by positivity)]
ring
_ = 2 * โ(2 * ฯ2 * Real.log (1 / ฮด)) *
โ a, โ j โ range (pullCount A a n ฯ), (1 / โj) := by
rw [sum_comp_pullCount (fun j => 1 / โj)]
_ โค 2 * โ(2 * ฯ2 * Real.log (1 / ฮด)) * (2 * โ a, โ(pullCount A a n ฯ)) := by -- loose
rw [mul_sum _ _ 2]
gcongr with a
by_cases ha : pullCount A a n ฯ = 0
ยท simp [ha]
ยท have hi := sum_inv_sqrt_le (Nat.pos_of_ne_zero ha)
rw [sum_range_succ] at hi
have : 0 โค 1 / โ(pullCount A a n ฯ) := by positivity
linarith
_ โค 2 * โ(2 * ฯ2 * Real.log (1 / ฮด)) * (2 * โ(K * โ a, (pullCount A a n ฯ))) := by
gcongr
have h := sum_sqrt_le Finset.univ (fun a => Nat.cast_nonneg (pullCount A a n ฯ))
rw [Finset.card_fin] at h
exact_mod_cast h
_ = 2 * โ(2 * ฯ2 * Real.log (1 / ฮด)) * (2 * โ(K * n)) := by
congr
exact sum_pullCount (ฯ := ฯ)
_ = 4 * โ(2 * ฯ2 * Real.log (1 / ฮด) * K * n) := by
ring_nf
rw [โ Real.sqrt_mul' _ (by positivity)]
ring_nfDependency graph
Type dependencies (3)
pullCount๐
Learning.pullCount
Number of times action a was chosen up to time t (excluding t).
Learning.pullCount.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (a : ๐) (t : โ) (ฯ : ฮฉ) : โLearning.pullCount.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ
Code
noncomputable def pullCount (A : โ โ ฮฉ โ ๐) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ := #(filter (fun s โฆ A s ฯ = a) (range t))
Actions: Source ยท Open Issue
empMean๐
Learning.empMean
Empirical mean reward obtained when pulling action a up to time t (exclusive).
Learning.empMean.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โLearning.empMean.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ
Code
noncomputable def empMean (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ := sumRewards A R' a t ฯ / pullCount A a t ฯ
Body uses (2)
Actions: Source ยท Open Issue
ucb๐
Bandits.ClippedUCB.ucbClipped upper confidence bound used in the regret analysis of Thompson sampling.
Bandits.ClippedUCB.ucb.{u_1} {K : โ} {ฮฉ : Type u_1} (A : โ โ ฮฉ โ Fin K) (R : โ โ ฮฉ โ โ) (l u ฯ2 ฮด : โ) (a : Fin K) (n : โ) (ฯ : ฮฉ) : โBandits.ClippedUCB.ucb.{u_1} {K : โ} {ฮฉ : Type u_1} (A : โ โ ฮฉ โ Fin K) (R : โ โ ฮฉ โ โ) (l u ฯ2 ฮด : โ) (a : Fin K) (n : โ) (ฯ : ฮฉ) : โ
Code
noncomputable def ucb (A : โ โ ฮฉ โ Fin K) (R : โ โ ฮฉ โ โ) (l u ฯ2 ฮด : โ) (a : Fin K) (n : โ) (ฯ : ฮฉ) : โ := if pullCount A a n ฯ = 0 then u else max l (min u (empMean A R a n ฯ + โ(2 * ฯ2 * Real.log (1 / ฮด) / (pullCount A a n ฯ))))
Actions: Source ยท Open Issue
All dependencies, transitively (1)
sumRewards๐
Learning.sumRewards
Sum of rewards obtained when pulling action a up to time t (exclusive).
Learning.sumRewards.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โLearning.sumRewards.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ
Code
def sumRewards (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ := โ s โ range t, if A s ฯ = a then R' s ฯ else 0
Used by (44)
Actions: Source ยท Open Issue