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.normal.Normal Class Reference

This bandit draws a reward from a set normal distribution each time an arm is chosen. More...

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

Public Member Functions

None __init__ (self, int k)
 Construct the class.
 
 select (self, index)
 Select one or several arms to obtain a reward from.
 
 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.
 

Protected Attributes

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

Detailed Description

This bandit draws a reward from a set normal distribution each time an arm is chosen.

Each arm has its own distribution that is fixed upon construction. Each distribution has a standard deviation of 1 and a mean randomly drawn from the uniform range [-1, 1).

Definition at line 5 of file normal.py.

Constructor & Destructor Documentation

◆ __init__()

None bandit.normal.Normal.__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.base_bandit.BaseBandit.

Reimplemented in bandit.random_walk.RandomWalk.

Definition at line 13 of file normal.py.

Member Function Documentation

◆ select()

bandit.normal.Normal.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.base_bandit.BaseBandit.

Reimplemented in bandit.random_walk.RandomWalk.

Definition at line 30 of file normal.py.

◆ trueValues()

bandit.normal.Normal.trueValues (   self)

Return the distribution parameters for the arms.

Returns
A tuple containing the parameters for each arm's distribution. The first element of the tuple will be a numpy array holding the means for each arm. The second element will also be a numpy array with the standard deviations.

Reimplemented from bandit.base_bandit.BaseBandit.

Definition at line 48 of file normal.py.

Member Data Documentation

◆ _mean

bandit.normal.Normal._mean
protected

Definition at line 28 of file normal.py.

◆ _std

bandit.normal.Normal._std
protected

Definition at line 26 of file normal.py.


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