Arms.UniformArm module¶

Uniformly distributed arm in [0, 1], or [lower, lower + amplitude].

Example of creating an arm:

>>> import random; import numpy as np
>>> random.seed(0); np.random.seed(0)
>>> Unif01 = UniformArm(0, 1)
>>> Unif01
U(0, 1)
>>> Unif01.mean
0.5


Examples of sampling from an arm:

>>> Unif01.draw()
0.8444...
>>> Unif01.draw_nparray(20)
array([0.54... , 0.71..., 0.60..., 0.54..., 0.42... ,
0.64..., 0.43..., 0.89...  , 0.96..., 0.38...,
0.79..., 0.52..., 0.56..., 0.92..., 0.07...,
0.08... , 0.02... , 0.83..., 0.77..., 0.87...])

class Arms.UniformArm.UniformArm(mini=0.0, maxi=1.0, mean=None, lower=0.0, amplitude=1.0)[source]

Bases: Arms.Arm.Arm

Uniformly distributed arm, default in [0, 1],

• default to (mini, maxi),

• or [lower, lower + amplitude], if (lower=lower, amplitude=amplitude) is given.

>>> arm_0_1 = UniformArm()
>>> arm_0_10 = UniformArm(0, 10)  # maxi = 10
>>> arm_2_4 = UniformArm(2, 4)
>>> arm_m10_10 = UniformArm(-10, 10)  # also UniformArm(lower=-10, amplitude=20)

__init__(mini=0.0, maxi=1.0, mean=None, lower=0.0, amplitude=1.0)[source]

New arm.

lower = None

Lower value of rewards

amplitude = None

Amplitude of rewards

mean = None

Mean for this UniformArm arm

draw(t=None)[source]

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

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

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

__str__()[source]

Return str(self).

__repr__()[source]

Return repr(self).

static kl(x, y)[source]

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

static oneLR(mumax, mu)[source]

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

__module__ = 'Arms.UniformArm'