Arms.Gamma module

Gamma distributed arm.

Example of creating an arm:

>>> import random; import numpy as np
>>> random.seed(0); np.random.seed(0)
>>> Gamma03 = GammaFromMean(0.3)
>>> Gamma03
\Gamma(0.3, 1)
>>> Gamma03.mean
0.3

Examples of sampling from an arm:

>>> Gamma03.draw()  
0.079...
>>> Gamma03.draw_nparray(20)  
array([1.35...e-01, 1.84...e-01, 5.71...e-02, 6.36...e-02,
       4.94...e-01, 1.51...e-01, 1.48...e-04, 2.25...e-06,
       4.56...e-01, 1.00...e+00, 7.59...e-02, 8.12...e-04,
       1.54...e-03, 1.14...e-01, 1.18...e-02, 7.30...e-02,
       1.76...e-06, 1.94...e-01, 1.00...e+00, 3.30...e-02])
class Arms.Gamma.Gamma(shape, scale=1.0, mini=0, maxi=1)[source]

Bases: Arms.Arm.Arm

Gamma distributed arm, possibly truncated.

__init__(shape, scale=1.0, mini=0, maxi=1)[source]

New arm.

shape = None

Shape parameter for this Gamma arm

scale = None

Scale parameter for this Gamma arm

mean = None

Mean for this Gamma arm

min = None

Lower value of rewards

max = None

Larger value of rewards

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.

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 Gaussian arms: (mumax - shape) / KL(shape, mumax).

oneHOI(mumax, mu)[source]

One term for the HOI factor for this arm.

__module__ = 'Arms.Gamma'
class Arms.Gamma.GammaFromMean(mean, scale=1.0, mini=0, maxi=1)[source]

Bases: Arms.Gamma.Gamma

Gamma distributed arm, possibly truncated, defined by its mean and not its scale parameter.

__init__(mean, scale=1.0, mini=0, maxi=1)[source]

As mean = scale * shape, shape = mean / scale is used.

__module__ = 'Arms.Gamma'
class Arms.Gamma.UnboundedGamma(shape, scale=1.0)[source]

Bases: Arms.Gamma.Gamma

Gamma distributed arm, not truncated, ie. supported in (-oo, oo).

__init__(shape, scale=1.0)[source]

New arm.

__module__ = 'Arms.Gamma'