Arms.Constant module

Arm with a constant reward. Useful for debugging.

Example of creating an arm:

>>> C013 = Constant(0.13)
>>> C013
Constant(0.13)
>>> C013.mean
0.13

Examples of sampling from an arm:

>>> C013.draw()
0.13
>>> C013.draw_nparray(3)
array([0.13, 0.13, 0.13])
class Arms.Constant.Constant(constant_reward=0.5, lower=0.0, amplitude=1.0)[source]

Bases: Arms.Arm.Arm

Arm with a constant reward. Useful for debugging.

  • constant_reward is the constant reward,

  • lower, amplitude default to floor(constant_reward), 1 (so the )

>>> arm_0_5 = Constant(0.5)
>>> arm_0_5.draw()
0.5
>>> arm_0_5.draw_nparray((3, 2))
array([[0.5, 0.5],
       [0.5, 0.5],
       [0.5, 0.5]])
__init__(constant_reward=0.5, lower=0.0, amplitude=1.0)[source]

New arm.

constant_reward = None

Constant value of rewards

lower = None

Known lower value of rewards

amplitude = None

Known amplitude of rewards

mean = None

Mean for this Constant arm

draw(t=None)[source]

Draw one constant sample. The parameter t is ignored in this Arm.

draw_nparray(shape=(1, ))[source]

Draw a numpy array of constant samples, of a certain shape.

set_mean_param(mean)[source]
__str__()[source]

Return str(self).

__repr__()[source]

Return repr(self).

static kl(x, y)[source]

The kl(x, y) = abs(x - y) to use for this arm.

static oneLR(mumax, mu)[source]

One term of the Lai & Robbins lower bound for Constant arms: (mumax - mu) / KL(mu, mumax).

__module__ = 'Arms.Constant'