Created
May 17, 2017 00:45
-
-
Save dustinandrews/c09c6f038cc618a045615b8baeb1e7ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bandit: | |
def __init__(self,arms : int): | |
self.arms = [] | |
for i in range(arms): | |
self.arms.append(np.random.rand()) | |
self.action_count = arms | |
def step(self, action: int): | |
reward = 0 | |
roll = np.random.rand() | |
if roll < self.arms[action]: | |
reward = 1 | |
else: | |
reward = -1 | |
return reward |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment