Skip to content

Instantly share code, notes, and snippets.

@dustinandrews
Created May 17, 2017 00:45
Show Gist options
  • Save dustinandrews/c09c6f038cc618a045615b8baeb1e7ac to your computer and use it in GitHub Desktop.
Save dustinandrews/c09c6f038cc618a045615b8baeb1e7ac to your computer and use it in GitHub Desktop.
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