k-Armed Bandit 1.0.0
A collection of k-armed bandits and assoicated agents for reinforcement learning
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
bandit.base_bandit.BaseBandit Class Reference

A base class for the various bandit implementations. More...

Inheritance diagram for bandit.base_bandit.BaseBandit:
bandit.normal.Normal bandit.static.Static bandit.tests.test_base_bandit.FakeBandit bandit.random_walk.RandomWalk

Public Member Functions

None __init__ (self, int k)
 Initialize the object with a set number of arms.
 
int k (self)
 Return the number of arms this bandit has.
 
 select (self, index)
 The method to select one of the arms of the bandit.
 
 trueValues (self)
 Return the true reward values of the bandit.
 

Protected Attributes

 _k
 

Detailed Description

A base class for the various bandit implementations.

This class defines several abstract methods and properties that must be implemented by any k-armed bandit implementation. This ensures consistent APIs across all of them.

Definition at line 4 of file base_bandit.py.

Constructor & Destructor Documentation

◆ __init__()

None bandit.base_bandit.BaseBandit.__init__ (   self,
int  k 
)

Initialize the object with a set number of arms.

Parameters
kThe number of arms this bandit should have. This must be an integer greater than zero.
Exceptions
ValueErrorif k is not an integer greater than zero.

Reimplemented in bandit.normal.Normal, bandit.random_walk.RandomWalk, bandit.tests.test_base_bandit.FakeBandit, and bandit.static.Static.

Definition at line 13 of file base_bandit.py.

Member Function Documentation

◆ k()

int bandit.base_bandit.BaseBandit.k (   self)

Return the number of arms this bandit has.

Returns
An int greater than or equal to one.

Definition at line 26 of file base_bandit.py.

◆ select()

bandit.base_bandit.BaseBandit.select (   self,
  index 
)

The method to select one of the arms of the bandit.

When implemented, this method should return the reward obtained when selecting the given arm index.

Parameters
indexSome sort of index representation to select which arms to get rewards from. Typically, this will be a single integer or some sort of list, array, etc. of integers.

Reimplemented in bandit.normal.Normal, bandit.random_walk.RandomWalk, bandit.static.Static, and bandit.tests.test_base_bandit.FakeBandit.

Definition at line 34 of file base_bandit.py.

◆ trueValues()

bandit.base_bandit.BaseBandit.trueValues (   self)

Return the true reward values of the bandit.

When implemented, this should provide the user with the complete truth of the bandit's state at the moment called. It is up to the implementation what exact information this is.

Reimplemented in bandit.normal.Normal, bandit.static.Static, and bandit.tests.test_base_bandit.FakeBandit.

Definition at line 47 of file base_bandit.py.

Member Data Documentation

◆ _k

bandit.base_bandit.BaseBandit._k
protected

Definition at line 23 of file base_bandit.py.


The documentation for this class was generated from the following file: