Sampling Best Response Dynamics


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
from brd import SamplingBRD

In [2]:
coordination_game_matrix = [[4, 0],
                            [3, 2]]
N = 20
sbrd0 = SamplingBRD(coordination_game_matrix, N=N)

In [3]:
ts_length = 100
m = 1
x = sbrd0.simulate(ts_length, init_action_dist=[N-m, m])
action = 1

fig, ax = plt.subplots(figsize=(8, 5))
ax.plot(x[:, action], linewidth=2, label='action {0}'.format(action))
ax.set_ylim(0, N)
plt.legend(loc=4)
plt.show()



In [4]:
young_game_matrix = [[6, 0, 0],
                     [5, 7, 5],
                     [0, 5, 8]]
N = 20
sbrd1 = SamplingBRD(young_game_matrix, N=N)

In [5]:
ts_length = 200
m = 2
x = sbrd1.simulate(ts_length, init_action_dist=[N-2*m, m, m])

fig, ax = plt.subplots(figsize=(8, 5))
for h in range(sbrd1.num_actions):
    ax.plot(x[:, h], linewidth=2, label='action {0}'.format(h))
ax.set_ylim(0, N)
plt.legend(loc=4)
plt.show()



In [5]: