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.
Default is to truncate into [0, 1] (so Gamma.draw() is in [0, 1]).
Cf. http://chercheurs.lille.inria.fr/ekaufman/NIPS13 Figure 1
-
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
-
property
lower_amplitude
¶ (lower, amplitude)
-
oneLR
(mumax, mu)[source]¶ One term of the Lai & Robbins lower bound for Gaussian arms: (mumax - shape) / KL(shape, mumax).
-
__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'¶
-