pub struct DiscountedThompsonSampling { /* private fields */ }Expand description
Thompson Sampling with exponential discounting (Qi+2023).
Extends standard Beta-Bernoulli Thompson Sampling with a forgetting factor that decays posterior parameters toward the prior on every step. This allows the algorithm to adapt in non-stationary environments where the best arm can change over time.
Used in irithyll’s AutoML module to select hyperparameter configurations when the optimal configuration may shift due to concept drift.
Implementations§
Source§impl DiscountedThompsonSampling
impl DiscountedThompsonSampling
Sourcepub fn new(n_arms: usize, discount: f64) -> Self
pub fn new(n_arms: usize, discount: f64) -> Self
Create a new DiscountedThompsonSampling bandit with the default
uniform Beta(1, 1) prior and seed 42.
§Panics
Panics if discount is not in (0, 1] or if n_arms is zero.
Sourcepub fn with_seed(n_arms: usize, discount: f64, seed: u64) -> Self
pub fn with_seed(n_arms: usize, discount: f64, seed: u64) -> Self
Create a new DiscountedThompsonSampling bandit with a custom RNG
seed and the default Beta(1, 1) prior.
§Panics
Panics if discount is not in (0, 1] or if n_arms is zero.
Sourcepub fn with_prior(
n_arms: usize,
discount: f64,
alpha_prior: f64,
beta_prior: f64,
) -> Self
pub fn with_prior( n_arms: usize, discount: f64, alpha_prior: f64, beta_prior: f64, ) -> Self
Create a new DiscountedThompsonSampling bandit with a custom
Beta(alpha, beta) prior for all arms and seed 42.
§Panics
Panics if alpha_prior or beta_prior are not positive, if
discount is not in (0, 1], or if n_arms is zero.
Sourcepub fn arm_alphas(&self) -> &[f64]
pub fn arm_alphas(&self) -> &[f64]
Per-arm posterior alpha parameters.
Trait Implementations§
Source§impl Bandit for DiscountedThompsonSampling
impl Bandit for DiscountedThompsonSampling
Source§fn select_arm(&mut self) -> usize
fn select_arm(&mut self) -> usize
Source§fn update(&mut self, arm: usize, reward: f64)
fn update(&mut self, arm: usize, reward: f64)
Source§fn arm_values(&self) -> &[f64]
fn arm_values(&self) -> &[f64]
Source§fn arm_counts(&self) -> &[u64]
fn arm_counts(&self) -> &[u64]
Source§impl Clone for DiscountedThompsonSampling
impl Clone for DiscountedThompsonSampling
Source§fn clone(&self) -> DiscountedThompsonSampling
fn clone(&self) -> DiscountedThompsonSampling
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DiscountedThompsonSampling
impl RefUnwindSafe for DiscountedThompsonSampling
impl Send for DiscountedThompsonSampling
impl Sync for DiscountedThompsonSampling
impl Unpin for DiscountedThompsonSampling
impl UnsafeUnpin for DiscountedThompsonSampling
impl UnwindSafe for DiscountedThompsonSampling
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more