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 | List of all members
bandit.random_walk.RandomWalk Class Reference

A random walk bandit. More...

Inheritance diagram for bandit.random_walk.RandomWalk:
bandit.normal.Normal bandit.base_bandit.BaseBandit

Public Member Functions

None __init__ (self, int k)
 Construct the class.
 
 select (self, index)
 Select one or several arms to obtain a reward from.
 
- Public Member Functions inherited from bandit.normal.Normal
 trueValues (self)
 Return the distribution parameters for the arms.
 
- Public Member Functions inherited from bandit.base_bandit.BaseBandit
int k (self)
 Return the number of arms this bandit has.
 

Additional Inherited Members

- Protected Attributes inherited from bandit.normal.Normal
 _std
 
 _mean
 
- Protected Attributes inherited from bandit.base_bandit.BaseBandit
 _k
 

Detailed Description

A random walk bandit.

This class features k arms with rewards from the arms drawn from normal distributions. The means, when initialized, are drawn from a uniform range of [-1, 1). However, after each call to select, the means for every arm is changed. Each arm's mean is adjusted by a randomly selected value drawn from a normal distribution with mean 0 and standard deviation 0.01. These values are drawn independently for each arm.

Definition at line 5 of file random_walk.py.

Constructor & Destructor Documentation

◆ __init__()

None bandit.random_walk.RandomWalk.__init__ (   self,
int  k 
)

Construct the class.

This includes defining the normal distribution parameters for each arm. There is a different distribution for each arm. The means are sampled from the uniform range [-1, 1). The standard deviations are 1.0.

Parameters
kThe number of arms this bandit should have. This must be an int greater than 0.

Reimplemented from bandit.normal.Normal.

Definition at line 17 of file random_walk.py.

Member Function Documentation

◆ select()

bandit.random_walk.RandomWalk.select (   self,
  index 
)

Select one or several arms to obtain a reward from.

Parameters
indexAny numpy valid indexing method to select which arms a reward should be drawn from. None can also be passed, but will only return a reward of None.
Returns
The rewards. The size of this will depend on the type of index. If a single integer is passed in, a single float will be returned. Otherwise, a numpy array will be returned. If None is passed in, this will also be None.

Reimplemented from bandit.normal.Normal.

Definition at line 20 of file random_walk.py.


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