Bandits.ucbAlgorithm
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.
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
Dependency graph
Type dependencies (1)
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
All dependencies, transitively (11)
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