Arms.Bernoulli module

Bernoulli distributed arm.

Example of creating an arm:

>>> import random; import numpy as np
>>> random.seed(0); np.random.seed(0)
>>> B03 = Bernoulli(0.3)
>>> B03
B(0.3)
>>> B03.mean
0.3

Examples of sampling from an arm:

>>> B03.draw()
0
>>> B03.draw_nparray(20)
array([1., 0., 0., 0., 0., 0., 1., 1., 0., 1., 0., 0., 1., 0., 0., 0., 1.,
       1., 1., 1.])
class Arms.Bernoulli.Bernoulli(probability)[source]

Bases: Arms.Arm.Arm

Bernoulli distributed arm.

__init__(probability)[source]

New arm.

probability = None

Parameter p for this Bernoulli arm

mean = None

Mean for this Bernoulli arm

draw(t=None)[source]

Draw one random sample.

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

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

set_mean_param(probability)[source]
property lower_amplitude

(lower, amplitude)

__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 Bernoulli arms: (mumax - mu) / KL(mu, mumax).

__module__ = 'Arms.Bernoulli'