Arms.Gaussian module

Gaussian distributed arm.

Example of creating an arm:

>>> import random; import numpy as np
>>> random.seed(0); np.random.seed(0)
>>> Gauss03 = Gaussian(0.3, 0.05)  # small variance
>>> Gauss03
N(0.3, 0.05)
>>> Gauss03.mean
0.3

Examples of sampling from an arm:

>>> Gauss03.draw()  
0.3470...
>>> Gauss03.draw_nparray(20)  
array([0.388..., 0.320..., 0.348... , 0.412..., 0.393... ,
       0.251..., 0.347..., 0.292..., 0.294..., 0.320...,
       0.307..., 0.372..., 0.338..., 0.306..., 0.322...,
       0.316..., 0.374..., 0.289..., 0.315..., 0.257...])
class Arms.Gaussian.Gaussian(mu, sigma=0.05, mini=0, maxi=1)[source]

Bases: Arms.Arm.Arm

Gaussian distributed arm, possibly truncated.

  • Default is to truncate into [0, 1] (so Gaussian.draw() is in [0, 1]).

__init__(mu, sigma=0.05, mini=0, maxi=1)[source]

New arm.

mu = None

Mean of Gaussian arm

mean = None

Mean of Gaussian arm

sigma = None

Variance of Gaussian arm

min = None

Lower value of rewards

max = None

Higher 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.

set_mean_param(mean)[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 Gaussian arms: (mumax - mu) / KL(mu, mumax).

oneHOI(mumax, mu)[source]

One term for the HOI factor for this arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_0_1(mu, sigma=0.05, mini=0, maxi=1)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [0, 1].

__init__(mu, sigma=0.05, mini=0, maxi=1)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_0_2(mu, sigma=0.1, mini=0, maxi=2)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [0, 2].

__init__(mu, sigma=0.1, mini=0, maxi=2)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_0_5(mu, sigma=0.5, mini=0, maxi=5)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [0, 5].

__init__(mu, sigma=0.5, mini=0, maxi=5)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_0_10(mu, sigma=1, mini=0, maxi=10)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [0, 10].

__init__(mu, sigma=1, mini=0, maxi=10)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_0_100(mu, sigma=5, mini=0, maxi=100)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [0, 100].

__init__(mu, sigma=5, mini=0, maxi=100)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_m1_1(mu, sigma=0.1, mini=-1, maxi=1)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [-1, 1].

__init__(mu, sigma=0.1, mini=-1, maxi=1)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_m2_2(mu, sigma=0.25, mini=-2, maxi=2)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [-2, 2].

__init__(mu, sigma=0.25, mini=-2, maxi=2)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_m5_5(mu, sigma=1, mini=-5, maxi=5)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [-5, 5].

__init__(mu, sigma=1, mini=-5, maxi=5)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_m10_10(mu, sigma=2, mini=-10, maxi=10)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [-10, 10].

__init__(mu, sigma=2, mini=-10, maxi=10)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.Gaussian_m100_100(mu, sigma=10, mini=-100, maxi=100)[source]

Bases: Arms.Gaussian.Gaussian

Gaussian distributed arm, truncated to [-100, 100].

__init__(mu, sigma=10, mini=-100, maxi=100)[source]

New arm.

__module__ = 'Arms.Gaussian'
class Arms.Gaussian.UnboundedGaussian(mu, sigma=1)[source]

Bases: Arms.Gaussian.Gaussian

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

__init__(mu, sigma=1)[source]

New 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.

__repr__()[source]

Return repr(self).

__module__ = 'Arms.Gaussian'