Skip to content

Instantly share code, notes, and snippets.

@AshNguyen
Created April 20, 2020 10:31
Show Gist options
  • Save AshNguyen/8866debcf567f97558b26ae16c950235 to your computer and use it in GitHub Desktop.
Save AshNguyen/8866debcf567f97558b26ae16c950235 to your computer and use it in GitHub Desktop.
ERL_majority
def majority_vote(p1, p2, p3):
'''
Takes three different probability vectors in and outputs a randomly
sampled action from n_action according to majority voting scheme
'''
a = range(n_action)
a1 = np.random.choice(a=a, p=p1)
a2 = np.random.choice(a=a, p=p2)
a3 = np.random.choice(a=a, p=p3)
l = [a1, a2, a3]
return max(set(l), key=l.count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment