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 | Public Attributes | Protected Attributes | List of all members
bandit.static.Static Class Reference

This class implements a bandit with a constant reward value each time an arm is chosen. More...

Inheritance diagram for bandit.static.Static:
bandit.base_bandit.BaseBandit

Public Member Functions

 __init__ (self, k, rewards=None)
 Instantiate the class.
 
 rewards (self)
 
 select (self, index)
 Get a reward from the chosen arm.
 
 trueValues (self)
 Provide a numpy array of the rewards for each arm.
 
- Public Member Functions inherited from bandit.base_bandit.BaseBandit
int k (self)
 Return the number of arms this bandit has.
 

Public Attributes

 k
 

Protected Attributes

 _rewards
 
- Protected Attributes inherited from bandit.base_bandit.BaseBandit
 _k
 

Detailed Description

This class implements a bandit with a constant reward value each time an arm is chosen.

The reward is not drawn from a distribution, nor does it change over time. The user can specify the reward values at instantiation if they want.

Definition at line 5 of file static.py.

Constructor & Destructor Documentation

◆ __init__()

bandit.static.Static.__init__ (   self,
  k,
  rewards = None 
)

Instantiate the class.

If reward_values is provided, it will be used for the reward values. Otherwise, a random value on the interval [0, 1) will be chosen for each arm.

Parameters
kAn int greater than or equal to one representing the number of arms this bandit has.
rewardsIf provided, the fixed reward for each arm. It can be a list, array, numpy array, or any sort of iterable object, but must have a length equal to k. It can also be None to let the bandit pick random rewards from the interval [0, 1).

Reimplemented from bandit.base_bandit.BaseBandit.

Definition at line 14 of file static.py.

Member Function Documentation

◆ rewards()

bandit.static.Static.rewards (   self)

Definition at line 38 of file static.py.

◆ select()

bandit.static.Static.select (   self,
  index 
)

Get a reward from the chosen arm.

Parameters
indexThe arm to pick. It can be any input that allows for indexing of a numpy array, including single integers or a set of integers.
Returns
The reward for that arm. The type will be either a single float if a single arm was chosen or an array of floats representing the rewards for each arm identified by index. If None is passed in to index, this will return None.

Reimplemented from bandit.base_bandit.BaseBandit.

Definition at line 41 of file static.py.

◆ trueValues()

bandit.static.Static.trueValues (   self)

Provide a numpy array of the rewards for each arm.

Returns
A numpy array where each index corresponds to the reward value for the associated arm at that index.

Reimplemented from bandit.base_bandit.BaseBandit.

Definition at line 61 of file static.py.

Member Data Documentation

◆ _rewards

bandit.static.Static._rewards
protected

Definition at line 30 of file static.py.

◆ k

bandit.static.Static.k

Definition at line 34 of file static.py.


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