def setUp(self): '''Setup a LogitDynamics instance''' # symmetric 2x2 coordination game payoff_matrix = [[4, 0], [3, 2]] beta = 4.0 g = NormalFormGame(payoff_matrix) self.ld = LogitDynamics(g, beta=beta)
def test_set_choice_probs_with_asymmetric_payoff_matrix(): bimatrix = np.array([[(4, 4), (1, 1), (0, 3)], [(3, 0), (1, 1), (2, 2)]]) beta = 1.0 g = NormalFormGame(bimatrix) ld = LogitDynamics(g, beta=beta) # (Normalized) CDFs of logit choice cdfs = np.ones((bimatrix.shape[1], bimatrix.shape[0])) cdfs[:, 0] = 1 / (1 + np.exp(beta*(bimatrix[1, :, 0]-bimatrix[0, :, 0]))) # self.ld.players[0].logit_choice_cdfs: unnormalized cdfs_computed = ld.players[0].logit_choice_cdfs cdfs_computed = cdfs_computed / cdfs_computed[..., [-1]] # Normalized assert_array_almost_equal_nulp(cdfs_computed, cdfs)