Skip to content

Instantly share code, notes, and snippets.

@drvinceknight
Created January 26, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drvinceknight/3cdd6bde6c0ff0f129cb to your computer and use it in GitHub Desktop.
Save drvinceknight/3cdd6bde6c0ff0f129cb to your computer and use it in GitHub Desktop.
from __future__ import division
import matplotlib.pyplot as plt
def plot(data):
row_player = [len([strategy for strategy in [row[0] for row in data[:round]] if strategy=='H'])/(round + 1) for round in range(len(data))]
column_player = [len([strategy for strategy in [row[1] for row in data[:round]] if strategy=='H'])/(round + 1) for round in range(len(data))]
plt.figure()
plt.scatter(range(len(row_player)), row_player, label='Player 1 probability of playing H')
plt.scatter(range(len(column_player)), column_player, color='red', label='Player 2 probability of playing T')
plt.plot([0, len(row_player)], [.5, .5], color='green', linestyle='-')
plt.plot([0, len(row_player)], [1/3, 1/3], color='gold', linestyle='-')
plt.legend()
plt.xlim(0, len(row_player))
plt.ylim(0, 1)
plt.savefig('modified_matching_pennies.png')
if __name__ == '__main__':
data = [['T','T'],
['H','H'],
['H','T'],
['T','H'],
['T','T'],
['H','H'],
['T','T'],
['H','H'],
['H','H'],
['T','H'],
['H','T'],
['H','T'],
['H','H'],
['H','T'],
['H','H'],
['H','T'],
['H','H'],
['H','T'],
['H','T'],
['T','T'],
['H','H'],
['H','H'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['H','T'],
['H','T'],
['H','H'],
['T','T'],
['T','T'],
['H','H'],
['T','H'],
['T','H'],
['T','T'],
['T','H'],
['T','T'],
['T','T'],
['T','H'],
['T','T'],
['H','H'],
['T','T'],
['H','T'],
['H','H'],
['T','T'],
['H','T'],
['H','T'],
['H','H'],
['H','T'],
['H','T'],
['T','H'],
['H','H'],
['H','T'],
['T','H'],
['T','T'],
['H','T'],
['T','T'],
['H','T'],
['T','T'],
['T','H'],
['H','T'],
['H','H'],
['T','H'],
['H','H'],
['T','H'],
['H','T'],
['H','H'],
['T','H'],
['H','H'],
['H','T'],
['H','T'],
['H','T'],
['H','T'],
['T','T'],
['T','H'],
['H','T'],
['T','T'],
['T','T'],
['H','H'],
['T','H'],
['H','T'],
['H','T'],
['H','T'],
['H','H'],
['T','T'],
['T','T'],
['H','T'],
['H','H'],
['T','T'],
['T','H'],
['H','T'],
['H','H'],
['H','H'],
['H','T'],
['H','T'],
['T','T'],
['T','T'],
['H','T'],
['H','H'],
['H','H'],
['H','T'],
['H','H'],
['H','T'],
['H','T'],
['H','T'],
['T','H'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['H','T'],
['T','H'],
['H','T'],
['H','H'],
['T','H'],
['H','T'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['H','T'],
['T','H'],
['T','T'],
['T','H'],
['T','T'],
['H','T'],
['T','T'],
['T','T'],
['H','H'],
['T','H'],
['T','T'],
['H','H'],
['H','H'],
['T','T'],
['T','T'],
['T','T'],
['T','H'],
['T','T'],
['T','T'],
['H','T'],
['T','T'],
['H','T'],
['H','T'],
['H','H'],
['T','T'],
['H','H'],
['H','H'],
['T','H'],
['H','T'],
['H','H'],
['T','H'],
['H','T'],
['T','H'],
['T','T'],
['T','T'],
['H','H'],
['T','T'],
['H','H'],
['T','T'],
['T','H'],
['H','H'],
['T','H'],
['H','H'],
['T','H'],
['H','H'],
['H','H'],
['T','T'],
['H','T'],
['T','T'],
['H','T'],
['T','H'],
['H','T'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['T','T'],
['H','T'],
['H','T'],
['T','T'],
['H','H'],
['T','H'],
['T','H'],
['T','T'],
['T','T'],
['T','T'],
['H','T'],
['T','H'],
['T','T'],
['T','T'],
['H','T'],
['H','T'],
['H','T'],
['T','T'],
['T','H'],
['T','H'],
['T','H'],
['H','H'],
['H','T'],
['T','T'],
['H','H'],
['T','H'],
['T','H'],
['T','T'],
['T','T'],
['H','T'],
['H','T'],
['H','T']]
plot(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment