LeanMachineLearning

Bandits.tsAlgorithmπŸ”—

Definition

The Thompson sampling algorithm with actions in Fin K, where Q : Measure 𝓔 is a prior distribution over parameters, and ΞΊ : Kernel (𝓔 Γ— Fin K) ℝ is a Markov kernel that defines the stationary environment stationaryEnv (ΞΊ.sectR e) that corresponds to a parameter e : 𝓔.

At every time n, the Thompson sampling policy uses the posterior over the parameters given the history up to time n to derive the probability of each action being optimal. The action for time n is sampled according to these probabilities.

πŸ”—def
Bandits.tsAlgorithm.{u_1} {K : β„•} {𝓔 : Type u_1} [MeasurableSpace 𝓔] [StandardBorelSpace 𝓔] [Nonempty 𝓔] (hK : 0 < K) (Q : MeasureTheory.Measure 𝓔) [MeasureTheory.IsProbabilityMeasure Q] (ΞΊ : ProbabilityTheory.Kernel (𝓔 Γ— Fin K) ℝ) [ProbabilityTheory.IsMarkovKernel ΞΊ] : Learning.Algorithm (Fin K) ℝ
Bandits.tsAlgorithm.{u_1} {K : β„•} {𝓔 : Type u_1} [MeasurableSpace 𝓔] [StandardBorelSpace 𝓔] [Nonempty 𝓔] (hK : 0 < K) (Q : MeasureTheory.Measure 𝓔) [MeasureTheory.IsProbabilityMeasure Q] (ΞΊ : ProbabilityTheory.Kernel (𝓔 Γ— Fin K) ℝ) [ProbabilityTheory.IsMarkovKernel ΞΊ] : Learning.Algorithm (Fin K) ℝ

Code

noncomputable def tsAlgorithm (hK : 0 < K) (Q : Measure 𝓔) [IsProbabilityMeasure Q] (ΞΊ : Kernel (𝓔 Γ— Fin K) ℝ) [IsMarkovKernel ΞΊ] : Algorithm (Fin K) ℝ where policy := TS.policy hK Q ΞΊ p0 := TS.initialPolicy hK Q ΞΊ

Actions: Source Β· Open Issue

Meaning last changed in v4.34.0-rc2-1-g439785b (2026-08-23), the 4th recorded change.

Self-contained, with its dependencies inlined and proofs replaced by sorry: download the raw file Β· open it in the Lean web editor.

Dependency graph

Audit surface: 19 project declarations, 74 external constants

βœ“ Proved: no sorry anywhere in its closure

This is the tool's own reading of one build's recorded axioms, and it is not robust against an author who wants it to pass. Checking meant to be relied on should go through Comparator, which replays the proof through the kernel from an export against an explicit list of permitted axioms.