2
$\begingroup$

enter image description here

I want to find the maximum value in each column by comparing only the first elements (-8 and 10) and (0 and -1) and maximum value in each row by comparing only the second elements {-8 and -10) and (0 and -1).Apparent (-8,-8) is the cell where are the max in both cases.So i want this result.I do not know how to do it with a matrix of this kind so I split the matrix into two A={{-8,0},{-10,-1}}and B={{-8,-10},{0,-1}} and I found max Relust is {0,-8} {0,-8} but i want to show {-8,-8} and if possible you do not have to separate the matrix like this.

$\endgroup$
  • $\begingroup$ I find it hard to grasp what you want. Please be more precise. For example: What do you want to find? A value as you said or a position? $\endgroup$ – Henrik Schumacher Nov 28 '18 at 17:41
  • $\begingroup$ Nash equilibria, such as the ones discussed here, are reported according to positions, not payoffs. The correct answer is not {-8,-8} but {1,1}. $\endgroup$ – Titus Nov 28 '18 at 22:57
2
$\begingroup$
(* payoff matrix: *)
payoff = {{{-8, -8}, {0, -10}}, {{-10, 0}, {-1, -1}}}
(* player 1 payoffs: *)
p01 = Map[First, payoff, {2}]
(* conditional best moves for player 1: *)
moves01 = Last /@ Ordering /@ Transpose[p01]
(* conditional payoffs for player 1: *)
payoffs01 = Extract[p01, MapIndexed[{#1, First@#2} &, moves01]]
$\endgroup$
0
$\begingroup$

I improved upon the answer by @Alan to show Player 2's responses and the coordinates of the equilibria (joint maxima). For a 2*3 (i,j) matrix,

payoff = {{{-8, -8}, {0, -10}}, {{-10, 0}, {-1, -1}}, {{-12, 0}, {1, 1}}};
p01 = Map[First, payoff, {2}];
p02 = Map[First, RotateLeft[payoff, {0, 0, -1}], {2}];
moves01 = Last /@ Ordering /@ Transpose[p01]
moves02 = Last /@ Ordering /@ p02
eq = Flatten /@ Table[If[{moves01[[i]], i} == {j, moves02[[j]]},{moves01[[i]], i}, Nothing], 
{i, 1, 2}, {j, 1, 3}]

The output is the optimal moves for each player and the position of the equilibria in the matrix.

{1, 3}

{1, 1, 2}

{{1, 1}, {3, 2}}

The code does NOT take into account indifference (two equal maximum values in each column). It will report only one.

The payoffs at equilibria are given by (apologies for elegance)

Table[Extract[payoff, eq[[i]]], {i, 1, 2}]

{{-8, -8}, {1, 1}}

$\endgroup$
  • $\begingroup$ When I run this code Table[Extract[payoff, eq[[i]]], {i, 1, 2}], it gives me these mistakes Part::partd: Part specification eq[[1]] is longer than depth of object. >>Extract::psl: Position specification eq[[1]] in Extract[{{{-8,-8},{0,-10}},{{-10,0},{-1,-1}},{{-12,0},{1,1}}},eq[[1]]] is not an integer or a list of integers. >>Part::partd: Part specification eq[[2]] is longer than depth of object. >> and I do not know how to fix them. Could this be for my version Wolfram mathematica 8.0? $\endgroup$ – M.Alexis Nov 29 '18 at 18:30
  • $\begingroup$ add eq= before the line Flatten/@etc. $\endgroup$ – Titus Nov 29 '18 at 19:04
  • $\begingroup$ I did it but again, such a mistake and no result. $\endgroup$ – M.Alexis Nov 29 '18 at 19:21
  • $\begingroup$ You are supposed to use both the first and the second block of code I provide, not just the last single line. I just tested it and it works fine. $\endgroup$ – Titus Nov 29 '18 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.