Source code for Policies.Uniform
# -*- coding: utf-8 -*-
""" Uniform: the fully uniform policy who selects randomly (uniformly) an arm at each step (stupid).
"""
__author__ = "Lilian Besson"
__version__ = "0.1"
import random
try:
from .BasePolicy import BasePolicy
except ImportError:
from BasePolicy import BasePolicy
[docs]class Uniform(BasePolicy):
""" Uniform: the fully uniform policy who selects randomly (uniformly) an arm at each step (stupid).
"""
[docs] def __init__(self, nbArms, lower=0., amplitude=1.):
"""Nothing to do."""
self.nbArms = nbArms #: Number of arms
[docs] def choice(self):
"""Uniform random choice between 0 and nbArms - 1 (included)."""
return random.randint(0, self.nbArms - 1)