Arms.Binomial module

Binomial distributed arm.

Example of creating an arm:

>>> import random; import numpy as np
>>> random.seed(0); np.random.seed(0)
>>> B03_10 = Binomial(0.3, 10)
>>> B03_10
Bin(0.3, 10)
>>> B03_10.mean
3.0

Examples of sampling from an arm:

>>> B03_10.draw()
3
>>> B03_10.draw_nparray(20)
array([4., 3., 3., 3., 3., 3., 5., 6., 3., 4., 3., 3., 5., 1., 1., 0., 4.,
       4., 5., 6.])
class Arms.Binomial.Binomial(probability, draws=1)[source]

Bases: Arms.Arm.Arm

Binomial distributed arm.

__init__(probability, draws=1)[source]

New arm.

probability = None

Parameter p for this Binomial arm

draws = None

Parameter n for this Binomial arm

mean = None

Mean for this Binomial 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.

set_mean_param(probability, draws=None)[source]
property lower_amplitude

(lower, amplitude)

__str__()[source]

Return str(self).

__repr__()[source]

Return repr(self).

kl(x, y)[source]

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

oneLR(mumax, mu)[source]

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

__module__ = 'Arms.Binomial'