Created
April 20, 2020 10:31
-
-
Save AshNguyen/8866debcf567f97558b26ae16c950235 to your computer and use it in GitHub Desktop.
ERL_majority
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
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