Bandits.UCB.expectation_pullCount_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.
expectation_pullCount_le'๐
Bandits.UCB.expectation_pullCount_le'Bound on the expectation of the number of pulls of each arm by the UCB algorithm.
Bandits.UCB.expectation_pullCount_le'.{u_1} {K : โ} {hK : 0 < K} {c : โ} {ฮฝ : ProbabilityTheory.Kernel (Fin K) โ} [ProbabilityTheory.IsMarkovKernel ฮฝ] {ฮฉ : Type u_1} {mฮฉ : MeasurableSpace ฮฉ} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ โ ฮฉ โ Fin K} {R : โ โ ฮฉ โ โ} {ฯ2 : NNReal} (h : Learning.IsAlgEnvSeq A R (ucbAlgorithm hK (c * โฯ2)) (Learning.stationaryEnv ฮฝ) P) (hฮฝ : โ (a : Fin K), ProbabilityTheory.HasSubgaussianMGF (fun x => x - โซ (x : โ), id x โฮฝ a) ฯ2 (ฮฝ a)) (hฯ2 : ฯ2 โ 0) (hc : 0 < c) (a : Fin K) (h_gap : 0 < gap ฮฝ a) (n : โ) : โซโป (ฯ : ฮฉ), โ(Learning.pullCount A a n ฯ) โP โค ENNReal.ofReal (8 * c * โฯ2 * Real.log (โn + 1) / gap ฮฝ a ^ 2 + 1) + 1 + 2 * constSum c nBandits.UCB.expectation_pullCount_le'.{u_1} {K : โ} {hK : 0 < K} {c : โ} {ฮฝ : ProbabilityTheory.Kernel (Fin K) โ} [ProbabilityTheory.IsMarkovKernel ฮฝ] {ฮฉ : Type u_1} {mฮฉ : MeasurableSpace ฮฉ} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ โ ฮฉ โ Fin K} {R : โ โ ฮฉ โ โ} {ฯ2 : NNReal} (h : Learning.IsAlgEnvSeq A R (ucbAlgorithm hK (c * โฯ2)) (Learning.stationaryEnv ฮฝ) P) (hฮฝ : โ (a : Fin K), ProbabilityTheory.HasSubgaussianMGF (fun x => x - โซ (x : โ), id x โฮฝ a) ฯ2 (ฮฝ a)) (hฯ2 : ฯ2 โ 0) (hc : 0 < c) (a : Fin K) (h_gap : 0 < gap ฮฝ a) (n : โ) : โซโป (ฯ : ฮฉ), โ(Learning.pullCount A a n ฯ) โP โค ENNReal.ofReal (8 * c * โฯ2 * Real.log (โn + 1) / gap ฮฝ a ^ 2 + 1) + 1 + 2 * constSum c n
Code
lemma expectation_pullCount_le'
(h : IsAlgEnvSeq A R (ucbAlgorithm hK (c * ฯ2)) (stationaryEnv ฮฝ) P)
(hฮฝ : โ a, HasSubgaussianMGF (fun x โฆ x - (ฮฝ a)[id]) ฯ2 (ฮฝ a))
(hฯ2 : ฯ2 โ 0) (hc : 0 < c) (a : Fin K) (h_gap : 0 < gap ฮฝ a) (n : โ) :
โซโป ฯ, pullCount A a n ฯ โP โค
ENNReal.ofReal (8 * c * ฯ2 * log (n + 1) / gap ฮฝ a ^ 2 + 1) + 1 + 2 * constSum c nType uses (6)
Body uses (12)
Used by (1)
Actions: Source ยท Open Issue
Proof
by
have hA := h.measurable_action
have hR := h.measurable_feedback
by_cases hn_zero : n = 0
ยท simp [hn_zero]
let C a : โ := โ8 * c * ฯ2 * log (n + 1) / gap ฮฝ a ^ 2โโ
have : Nonempty (Fin K) := Fin.pos_iff_nonempty.mp hK
have h_set_1 b : MeasurableSet {a_1 | 0 < pullCount A a b a_1 โง
(ฮฝ a)[id] < empMean A R a b a_1 - ucbWidth A (c * ฯ2) a b a_1} := by
change MeasurableSet ({a_1 | 0 < pullCount A a b a_1} โฉ
{a_1 | (ฮฝ a)[id] < empMean A R a b a_1 - ucbWidth A (c * ฯ2) a b a_1})
exact (measurableSet_lt (by fun_prop) (by fun_prop)).inter
(measurableSet_lt (by fun_prop) (by fun_prop))
have h_set_2 b : MeasurableSet {a | 0 < pullCount A (bestArm ฮฝ) b a โง
empMean A R (bestArm ฮฝ) b a + ucbWidth A (c * ฯ2) (bestArm ฮฝ) b a < (ฮฝ (bestArm ฮฝ))[id]} := by
change MeasurableSet ({a | 0 < pullCount A (bestArm ฮฝ) b a} โฉ
{a | empMean A R (bestArm ฮฝ) b a + ucbWidth A (c * ฯ2) (bestArm ฮฝ) b a < (ฮฝ (bestArm ฮฝ))[id]})
exact (measurableSet_lt (by fun_prop) (by fun_prop)).inter
(measurableSet_lt (by fun_prop) (by fun_prop))
have h_meas_1 b : Measurable fun h โฆ {s | 0 < pullCount A a s h โง (ฮฝ a)[id] <
empMean A R a s h - ucbWidth A (c * ฯ2) a s h}.indicator (1 : โ โ โ) b := by
simp only [id_eq, Set.indicator_apply, Set.mem_setOf_eq, Pi.one_apply]
exact Measurable.ite (h_set_1 _) (by fun_prop) (by fun_prop)
have h_meas_2 b : Measurable fun h โฆ {s | 0 < pullCount A (bestArm ฮฝ) s h โง
empMean A R (bestArm ฮฝ) s h + ucbWidth A (c * ฯ2) (bestArm ฮฝ) s h <
(ฮฝ (bestArm ฮฝ))[id]}.indicator (1 : โ โ โ) b := by
simp only [id_eq, Set.indicator_apply, Set.mem_setOf_eq, Pi.one_apply]
exact Measurable.ite (h_set_2 _) (by fun_prop) (by fun_prop)
calc โซโป ฯ, pullCount A a n ฯ โP
_ โค โซโป ฯ, C a + 1 +
โ s โ range n,
{s | 0 < pullCount A (bestArm ฮฝ) s ฯ โง
empMean A R (bestArm ฮฝ) s ฯ + ucbWidth A (c * ฯ2) (bestArm ฮฝ) s ฯ <
(ฮฝ (bestArm ฮฝ))[id]}.indicator (1 : โ โ โ) s +
โ s โ range n,
{s | 0 < pullCount A a s ฯ โง (ฮฝ a)[id] <
empMean A R a s ฯ - ucbWidth A (c * ฯ2) a s ฯ}.indicator (1 : โ โ โ) s โP := by
refine lintegral_mono_ae ?_
have hCa : C a โ 0 := by
simp only [ne_eq, Nat.ceil_eq_zero, not_le, C]
have : 0 < log (n + 1) := log_pos (by simp; grind)
positivity
filter_upwards [pullCount_ae_le_add_two h hc.le a h_gap n (C a) hCa (Nat.le_ceil _)] with ฯ hฯ
simp only [id_eq, Nat.cast_sum]
norm_cast
_ โค (C a : โโฅ0โ) + 1 +
โ s โ range n,
P {ฯ | 0 < pullCount A (bestArm ฮฝ) s ฯ โง
empMean A R (bestArm ฮฝ) s ฯ + ucbWidth A (c * ฯ2) (bestArm ฮฝ) s ฯ < (ฮฝ (bestArm ฮฝ))[id]} +
โ s โ range n,
P {ฯ | 0 < pullCount A a s ฯ โง (ฮฝ a)[id] <
empMean A R a s ฯ - ucbWidth A (c * ฯ2) a s ฯ} := by
simp only [id_eq, Nat.cast_sum]
rw [lintegral_add_left (by fun_prop), lintegral_add_left (by fun_prop)]
simp only [lintegral_const, measure_univ, mul_one]
rw [lintegral_finsetSum _ (by fun_prop), lintegral_finsetSum _ (by fun_prop)]
gcongr with k hk k hk
ยท rw [โ lintegral_indicator_one]
swap; ยท exact h_set_2 _
gcongr with h
simp [Set.indicator_apply]
ยท rw [โ lintegral_indicator_one]
swap; ยท exact h_set_1 _
gcongr with h
simp [Set.indicator_apply]
_ โค (C a : โโฅ0โ) + 1 +
โ s โ range n, 1 / ((s : โโฅ0โ) + 1) ^ (c - 1) +
โ s โ range n, 1 / ((s : โโฅ0โ) + 1) ^ (c - 1) := by
gcongr with s hs s hs
ยท refine (measure_mono ?_).trans (prob_ucbIndex_le h hฮฝ hฯ2 (by positivity) (bestArm ฮฝ) s)
grind
ยท refine (measure_mono ?_).trans (prob_ucbIndex_ge h hฮฝ hฯ2 (by positivity) a s)
grind
_ โค ENNReal.ofReal (8 * c * ฯ2 * log (n + 1) / gap ฮฝ a ^ 2 + 1) + 1 + 2 * constSum c n := by
rw [two_mul, add_assoc, constSum]
gcongr
simp only [C]
rw [โ ENNReal.ofReal_natCast]
refine ENNReal.ofReal_le_ofReal ?_
refine (Nat.ceil_lt_add_one ?_).le
have : 0 โค log (n + 1) := log_nonneg (by simp)
positivityDependency graph
Type dependencies (6)
IsAlgEnvSeq๐
Learning.IsAlgEnvSeqAn algorithm-environment sequence: a sequence of actions and feedbacks generated by an algorithm interacting with an environment.
Learning.IsAlgEnvSeq.{u_1, u_2, u_3} {๐ : Type u_1} {๐จ : Type u_2} {ฮฉ : Type u_3} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} {mฮฉ : MeasurableSpace ฮฉ} (A : โ โ ฮฉ โ ๐) (Y : โ โ ฮฉ โ ๐จ) (alg : Algorithm ๐ ๐จ) (env : Environment ๐ ๐จ) (P : MeasureTheory.Measure ฮฉ) [MeasureTheory.IsFiniteMeasure P] : PropLearning.IsAlgEnvSeq.{u_1, u_2, u_3} {๐ : Type u_1} {๐จ : Type u_2} {ฮฉ : Type u_3} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} {mฮฉ : MeasurableSpace ฮฉ} (A : โ โ ฮฉ โ ๐) (Y : โ โ ฮฉ โ ๐จ) (alg : Algorithm ๐ ๐จ) (env : Environment ๐ ๐จ) (P : MeasureTheory.Measure ฮฉ) [MeasureTheory.IsFiniteMeasure P] : Prop
Code
structure IsAlgEnvSeq
(A : โ โ ฮฉ โ ๐) (Y : โ โ ฮฉ โ ๐จ) (alg : Algorithm ๐ ๐จ) (env : Environment ๐ ๐จ)
(P : Measure ฮฉ) [IsFiniteMeasure P] : Prop where
/-- The action sequence is measurable. -/
measurable_action n : Measurable (A n) := by fun_prop
/-- The feedback sequence is measurable. -/
measurable_feedback n : Measurable (Y n) := by fun_prop
/-- The first action has the correct law. -/
hasLaw_action_zero : HasLaw (fun ฯ โฆ (A 0 ฯ)) alg.p0 P
/-- The first feedback has the correct conditional distribution. -/
hasCondDistrib_feedback_zero : HasCondDistrib (Y 0) (A 0) env.ฮฝ0 P
/-- The next action has the correct conditional distribution given the history. -/
hasCondDistrib_action n :
HasCondDistrib (A (n + 1)) (history A Y n) (alg.policy n) P
/-- The next feedback has the correct conditional distribution given the history and
next action. -/
hasCondDistrib_feedback n :
HasCondDistrib (Y (n + 1)) (fun ฯ โฆ (history A Y n ฯ, A (n + 1) ฯ))
(env.feedback n) PType uses (3)
Used by (111)
Actions: Source ยท Open Issue
ucbAlgorithm๐
Bandits.ucbAlgorithmThe UCB algorithm.
Bandits.ucbAlgorithm {K : โ} (hK : 0 < K) (c : โ) : Learning.Algorithm (Fin K) โBandits.ucbAlgorithm {K : โ} (hK : 0 < K) (c : โ) : Learning.Algorithm (Fin K) โ
Code
noncomputable def ucbAlgorithm (hK : 0 < K) (c : โ) : Algorithm (Fin K) โ := detAlgorithm (UCB.nextArm hK c) (by fun_prop) โจ0, hKโฉ
Type uses (1)
Body uses (3)
Used by (16)
Actions: Source ยท Open Issue
stationaryEnv๐
Learning.stationaryEnvA stationary environment, in which the distribution of the next feedback depends only on the last action.
Learning.stationaryEnv.{u_1, u_2} {๐ : Type u_1} {๐จ : Type u_2} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} (ฮฝ : ProbabilityTheory.Kernel ๐ ๐จ) [ProbabilityTheory.IsMarkovKernel ฮฝ] : Environment ๐ ๐จLearning.stationaryEnv.{u_1, u_2} {๐ : Type u_1} {๐จ : Type u_2} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} (ฮฝ : ProbabilityTheory.Kernel ๐ ๐จ) [ProbabilityTheory.IsMarkovKernel ฮฝ] : Environment ๐ ๐จ
Code
def stationaryEnv (ฮฝ : Kernel ๐ ๐จ) [IsMarkovKernel ฮฝ] : Environment ๐ ๐จ := obliviousEnv fun _ โฆ ฮฝ
Type uses (1)
Body uses (1)
Used by (81)
Actions: Source ยท Open Issue
gap๐
Bandits.gap
Gap of an action a: difference between the highest mean of the actions and the mean of a.
Bandits.gap.{u_1} {๐ : Type u_1} {m๐ : MeasurableSpace ๐} (ฮฝ : ProbabilityTheory.Kernel ๐ โ) (a : ๐) : โBandits.gap.{u_1} {๐ : Type u_1} {m๐ : MeasurableSpace ๐} (ฮฝ : ProbabilityTheory.Kernel ๐ โ) (a : ๐) : โ
Code
noncomputable def gap (ฮฝ : Kernel ๐ โ) (a : ๐) : โ := (โจ i, (ฮฝ i)[id]) - (ฮฝ a)[id]
Used by (27)
Actions: Source ยท Open Issue
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
constSum๐
Bandits.UCB.constSumA sum that appears in the UCB regret upper bound.
Bandits.UCB.constSum (c : โ) (n : โ) : ENNRealBandits.UCB.constSum (c : โ) (n : โ) : ENNReal
Code
noncomputable def constSum (c : โ) (n : โ) : โโฅ0โ := โ s โ range n, 1 / ((s : โโฅ0โ) + 1) ^ (c - 1)
Actions: Source ยท Open Issue
All dependencies, transitively (15)
Algorithm๐
Learning.AlgorithmA stochastic, sequential algorithm.
Learning.Algorithm.{u_4, u_5} (๐ : Type u_4) (๐จ : Type u_5) [MeasurableSpace ๐] [MeasurableSpace ๐จ] : Type (max u_4 u_5)Learning.Algorithm.{u_4, u_5} (๐ : Type u_4) (๐จ : Type u_5) [MeasurableSpace ๐] [MeasurableSpace ๐จ] : Type (max u_4 u_5)
Code
structure Algorithm (๐ ๐จ : Type*) [MeasurableSpace ๐] [MeasurableSpace ๐จ] where /-- Policy or sampling rule: distribution of the next action. -/ policy : (n : โ) โ Kernel (Iic n โ ๐ ร ๐จ) ๐ /-- The policy is a Markov kernel. -/ [h_policy : โ n, IsMarkovKernel (policy n)] /-- Distribution of the first action. -/ p0 : Measure ๐ /-- The first action distribution is a probability measure. -/ [hp0 : IsProbabilityMeasure p0]
Used by (216)
Actions: Source ยท Open Issue
Environment๐
Learning.EnvironmentA stochastic environment.
Learning.Environment.{u_4, u_5} (๐ : Type u_4) (๐จ : Type u_5) [MeasurableSpace ๐] [MeasurableSpace ๐จ] : Type (max u_4 u_5)Learning.Environment.{u_4, u_5} (๐ : Type u_4) (๐จ : Type u_5) [MeasurableSpace ๐] [MeasurableSpace ๐จ] : Type (max u_4 u_5)
Code
structure Environment (๐ ๐จ : Type*) [MeasurableSpace ๐] [MeasurableSpace ๐จ] where /-- Distribution of the next observation as function of the past history. -/ feedback : (n : โ) โ Kernel ((Iic n โ ๐ ร ๐จ) ร ๐) ๐จ /-- The feedback kernels are Markov kernels. -/ [h_feedback : โ n, IsMarkovKernel (feedback n)] /-- Distribution of the first observation given the first action. -/ ฮฝ0 : Kernel ๐ ๐จ /-- The initial observation kernel is a Markov kernel. -/ [hp0 : IsMarkovKernel ฮฝ0]
Actions: Source ยท Open Issue
history๐
Learning.history
History of the algorithm-environment sequence up to time n.
Learning.history.{u_1, u_2, u_3} {๐ : Type u_1} {๐จ : Type u_2} {ฮฉ : Type u_3} (A : โ โ ฮฉ โ ๐) (Y : โ โ ฮฉ โ ๐จ) (n : โ) (ฯ : ฮฉ) : โฅ(Finset.Iic n) โ ๐ ร ๐จLearning.history.{u_1, u_2, u_3} {๐ : Type u_1} {๐จ : Type u_2} {ฮฉ : Type u_3} (A : โ โ ฮฉ โ ๐) (Y : โ โ ฮฉ โ ๐จ) (n : โ) (ฯ : ฮฉ) : โฅ(Finset.Iic n) โ ๐ ร ๐จ
Code
def history (A : โ โ ฮฉ โ ๐) (Y : โ โ ฮฉ โ ๐จ) (n : โ) (ฯ : ฮฉ) : Iic n โ ๐ ร ๐จ := fun i โฆ (A i ฯ, Y i ฯ)
Actions: Source ยท Open Issue
detAlgorithm๐
Learning.detAlgorithm
A deterministic algorithm, which chooses the action given by the function nextAction.
Learning.detAlgorithm.{u_1, u_2} {๐ : Type u_1} {๐จ : Type u_2} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} (nextA : (n : โ) โ (โฅ(Finset.Iic n) โ ๐ ร ๐จ) โ ๐) (h_next : โ (n : โ), Measurable (nextA n)) (action0 : ๐) : Algorithm ๐ ๐จLearning.detAlgorithm.{u_1, u_2} {๐ : Type u_1} {๐จ : Type u_2} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} (nextA : (n : โ) โ (โฅ(Finset.Iic n) โ ๐ ร ๐จ) โ ๐) (h_next : โ (n : โ), Measurable (nextA n)) (action0 : ๐) : Algorithm ๐ ๐จ
Code
noncomputable
def detAlgorithm (nextA : (n : โ) โ (Iic n โ ๐ ร ๐จ) โ ๐)
(h_next : โ n, Measurable (nextA n)) (action0 : ๐) :
Algorithm ๐ ๐จ where
policy n := Kernel.deterministic (nextA n) (h_next n)
p0 := Measure.dirac action0Type uses (1)
Used by (15)
Actions: Source ยท Open Issue
nextAction๐
Learning.RoundRobin.nextAction
Action chosen by the Round-Robin algorithm at time n + 1. This is action (n + 1) % K.
Learning.RoundRobin.nextAction {K : โ} (hK : 0 < K) (n : โ) : Fin KLearning.RoundRobin.nextAction {K : โ} (hK : 0 < K) (n : โ) : Fin K
Code
noncomputable def RoundRobin.nextAction (hK : 0 < K) (n : โ) : Fin K := โจ(n + 1) % K, Nat.mod_lt _ hKโฉ
Used by (14)
Actions: Source ยท Open Issue
max๐
Function.maxThe maximum value of a tuple.
Function.max.{u_1, u_2} {ฮน : Type u_1} {ฮฑ : Type u_2} [LinearOrder ฮฑ] [Fintype ฮน] [Nonempty ฮน] (f : ฮน โ ฮฑ) : ฮฑFunction.max.{u_1, u_2} {ฮน : Type u_1} {ฮฑ : Type u_2} [LinearOrder ฮฑ] [Fintype ฮน] [Nonempty ฮน] (f : ฮน โ ฮฑ) : ฮฑ
Code
abbrev max : ฮฑ := univ.sup' univ_nonempty f
Used by (8)
Actions: Source ยท Open Issue
exists_argmax๐
exists_argmaxNo docstring.
exists_argmax.{u_1, u_2} {ฮน : Type u_1} {ฮฑ : Type u_2} [LinearOrder ฮฑ] [Fintype ฮน] [Nonempty ฮน] (f : ฮน โ ฮฑ) : โ i, f i = Function.max fexists_argmax.{u_1, u_2} {ฮน : Type u_1} {ฮฑ : Type u_2} [LinearOrder ฮฑ] [Fintype ฮน] [Nonempty ฮน] (f : ฮน โ ฮฑ) : โ i, f i = Function.max f
Code
lemma exists_argmax : โ i, f i = f.max
Type uses (1)
Used by (3)
Actions: Source ยท Open Issue
Proof
by obtain โจi, -, hiโฉ := Finset.exists_mem_eq_sup' (by simp : Finset.univ.Nonempty) f exact โจi, hi.symmโฉ
argmax๐
argmaxThe index of the maximum value of a tuple.
argmax.{u_1, u_2} {ฮน : Type u_1} {ฮฑ : Type u_2} [LinearOrder ฮฑ] [Fintype ฮน] [Nonempty ฮน] (f : ฮน โ ฮฑ) : ฮนargmax.{u_1, u_2} {ฮน : Type u_1} {ฮฑ : Type u_2} [LinearOrder ฮฑ] [Fintype ฮน] [Nonempty ฮน] (f : ฮน โ ฮฑ) : ฮน
Code
noncomputable def argmax := (exists_argmax f).choose
Body uses (2)
Used by (17)
Actions: Source ยท Open Issue
sumRewards'๐
Learning.sumRewards'
Sum of rewards of arm a up to (and including) time n.
Learning.sumRewards'.{u_1} {๐ : Type u_1} [DecidableEq ๐] (n : โ) (h : โฅ(Finset.Iic n) โ ๐ ร โ) (a : ๐) : โLearning.sumRewards'.{u_1} {๐ : Type u_1} [DecidableEq ๐] (n : โ) (h : โฅ(Finset.Iic n) โ ๐ ร โ) (a : ๐) : โ
Code
noncomputable def sumRewards' (n : โ) (h : Iic n โ ๐ ร โ) (a : ๐) := โ s, if (h s).1 = a then (h s).2 else 0
Used by (9)
Actions: Source ยท Open Issue
pullCount'๐
Learning.pullCount'
Number of pulls of arm a up to (and including) time n.
This is the number of entries in h in which the arm is a.
Learning.pullCount'.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} [DecidableEq ๐] (n : โ) (h : โฅ(Finset.Iic n) โ ๐ ร R) (a : ๐) : โLearning.pullCount'.{u_1, u_2} {๐ : Type u_1} {R : Type u_2} [DecidableEq ๐] (n : โ) (h : โฅ(Finset.Iic n) โ ๐ ร R) (a : ๐) : โ
Code
noncomputable
def pullCount' (n : โ) (h : Iic n โ ๐ ร R) (a : ๐) := #{s | (h s).1 = a}Used by (29)
Actions: Source ยท Open Issue
empMean'๐
Learning.empMean'
Empirical mean of arm a at time n.
Learning.empMean'.{u_1} {๐ : Type u_1} [DecidableEq ๐] (n : โ) (h : โฅ(Finset.Iic n) โ ๐ ร โ) (a : ๐) : โLearning.empMean'.{u_1} {๐ : Type u_1} [DecidableEq ๐] (n : โ) (h : โฅ(Finset.Iic n) โ ๐ ร โ) (a : ๐) : โ
Code
noncomputable def empMean' (n : โ) (h : Iic n โ ๐ ร โ) (a : ๐) := (sumRewards' n h a) / (pullCount' n h a)
Body uses (2)
Used by (18)
Actions: Source ยท Open Issue
ucbWidth'๐
Bandits.ucbWidth'The exploration bonus of the UCB algorithm, which corresponds to the width of a confidence interval.
Bandits.ucbWidth' {K : โ} (c : โ) (n : โ) (h : โฅ(Finset.Iic n) โ Fin K ร โ) (a : Fin K) : โBandits.ucbWidth' {K : โ} (c : โ) (n : โ) (h : โฅ(Finset.Iic n) โ Fin K ร โ) (a : Fin K) : โ
Code
noncomputable def ucbWidth' (c : โ) (n : โ) (h : Iic n โ Fin K ร โ) (a : Fin K) : โ := โ(2 * c * log (n + 2) / pullCount' n h a)
Body uses (1)
Used by (6)
Actions: Source ยท Open Issue
nextArm๐
Bandits.UCB.nextArm
Arm pulled by the UCB algorithm at time n + 1.
Bandits.UCB.nextArm {K : โ} (hK : 0 < K) (c : โ) (n : โ) (h : โฅ(Finset.Iic n) โ Fin K ร โ) : Fin KBandits.UCB.nextArm {K : โ} (hK : 0 < K) (c : โ) (n : โ) (h : โฅ(Finset.Iic n) โ Fin K ร โ) : Fin K
Code
noncomputable def UCB.nextArm (hK : 0 < K) (c : โ) (n : โ) (h : Iic n โ Fin K ร โ) : Fin K := have : Nonempty (Fin K) := Fin.pos_iff_nonempty.mp hK if n < K - 1 then RoundRobin.nextAction hK n else argmax (fun a โฆ empMean' n h a + ucbWidth' c n h a)
Body uses (4)
Used by (7)
Actions: Source ยท Open Issue
measurable_nextArm๐
Bandits.UCB.measurable_nextArmNo docstring.
Bandits.UCB.measurable_nextArm {K : โ} (hK : 0 < K) (c : โ) (n : โ) : Measurable (nextArm hK c n)Bandits.UCB.measurable_nextArm {K : โ} (hK : 0 < K) (c : โ) (n : โ) : Measurable (nextArm hK c n)
Code
lemma UCB.measurable_nextArm (hK : 0 < K) (c : โ) (n : โ) : Measurable (nextArm hK c n)
Type uses (1)
Body uses (9)
Actions: Source ยท Open Issue
Proof
by refine Measurable.ite (by simp) (by fun_prop) ?_ have : Nonempty (Fin K) := Fin.pos_iff_nonempty.mp hK unfold ucbWidth' fun_prop
obliviousEnv๐
Learning.obliviousEnvAn oblivious environment, in which the distribution of the next feedback depends only on the last action, but in a possibly time-dependent manner.
Learning.obliviousEnv.{u_1, u_2} {๐ : Type u_1} {๐จ : Type u_2} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} (ฮฝ : โ โ ProbabilityTheory.Kernel ๐ ๐จ) [โ (n : โ), ProbabilityTheory.IsMarkovKernel (ฮฝ n)] : Environment ๐ ๐จLearning.obliviousEnv.{u_1, u_2} {๐ : Type u_1} {๐จ : Type u_2} {m๐ : MeasurableSpace ๐} {m๐จ : MeasurableSpace ๐จ} (ฮฝ : โ โ ProbabilityTheory.Kernel ๐ ๐จ) [โ (n : โ), ProbabilityTheory.IsMarkovKernel (ฮฝ n)] : Environment ๐ ๐จ
Code
def obliviousEnv (ฮฝ : โ โ Kernel ๐ ๐จ) [โ n, IsMarkovKernel (ฮฝ n)] : Environment ๐ ๐จ where feedback n := (ฮฝ (n + 1)).prodMkLeft _ ฮฝ0 := ฮฝ 0
Type uses (1)
Used by (10)
Actions: Source ยท Open Issue