(* :Mathematica Version: 2.2 *)
(* :Context: Dynamics` *)
(* :Title: Discrete *)
(* :Author: B.E. Fitelson *)
(* :Summary: This package contains several functions for
performing various kinds of simulations and
stability analyses of the (discrete time)
deliberational dynamics of 2x2 Normal-Form games.
Included are functions for (numerically) generating
graphics objects of orbits and under both Darwin and
Nash discrete dynamical maps. Moreover,
there are functions defined for both finding and
performing analytical stability analyses of the
Nash equilibria of 2x2 games under Darwin dynamics.*)
(* :Sources: "The Dynamics of Rational Deliberation",
Brian Skyrms, Harvard, 1990.*)
BeginPackage["Discrete`"]
DarwinOrbit::usage =
"DarwinOrbit[{G_, K_, SAT_, IMAX_, PrR20_, PrC20_}].
Takes the five-tuple into a
graphics object of the orbit starting from the initial
point under Darwin dynamics. Here,
SAT is the satisficing index (IMAX is the maximum
number of iterations allowed), and K is the index of
caution. G is the 2x2 Normal form game--it is an
eight-tuple of the form:
G = {R11, C11, R12, C12, R21, C21, R22, C22}
See Skyrms (1990) Appendices for details."
NashOrbit::usage =
"NashOrbit[{G_, K_, SAT_, IMAX_, PrR20_, PrC20_}]
Takes the five-tuple
into a graphics object of the orbit starting from the
initial point under Nash dynamics. Here,
SAT is the satisficing index (IMAX is the maximum
number of iterations allowed), and K is the index of
caution. G is the 2x2 Normal form game--it is an
eight-tuple of the form:
G = {R11, C11, R12, C12, R21, C21, R22, C22}
See Skyrms (1990) Appendices for details."
DarwinStability::usage =
"DarwinStability[G_], (1) finds all of the Nash
equilibria of the 2x2 Normal-Form game G, and then
(2) performs a linear stability analysis for
the discrete time Darwin dynamical map at each of these
equilibria. Specifically, this function outputs the
absolute values of the eigenvalues of the Jacobian
Matrix of the Darwin map of G at each of its Nash points."
Nash::usage ="Nash[game_] finds the Nash Equilibria of game, a game in
normal form. Example input: Nash[{{{2,1},{0,0}},{{0,0},{1,2}}}]. Nash
returns the probability weights on the different pure strategies."
IsNash::usage ="IsNash[game_,strategies_] returns True if strategies is
a Nash Equilibrium of game and False otherwise.
Example input: IsNash[game,{{2/3,1/3},{1/3,2/3}}]."
Begin["DarwinOrbit`Private`"]
DarwinOrbit[{G_, K_, SAT_, IMAX_, PrR20_, PrC20_}] :=
(
(**Setting the Initial 'State of Indecision'**)
{R11, C11, R12, C12,
R21, C21, R22, C22} = G;
PrR2=PrR20;
PrC2=PrC20;
(**Main Loop Structure**)
covC1=1;
i=0;
data={{PrR2, PrC2}};
While[(covR1>SAT || covR2>SAT || covC1>SAT || covC2>SAT) && iSAT || covR2>SAT || covC1>SAT || covC2>SAT) && i=0 && N[x[[i]]]<=1,{i,1,Length[x]}]];
a1list=Union[Select[Select[a1list,nq],pn]];
a2list=Union[Select[Select[a2list,nq],pn]];
nlist=Flatten[Table[{a1list[[i]],a2list[[j]]},{i,1,Length[a1list]},
{j,1,Length[a2list]}],1];
INash[S_]:=Isnash[a,S];
NashE=Select[nlist,INash]
];
DarwinStability[G_] :=
(
(**Calculate Expected Utilities (SQ=Status Quo)**)
{R11, C11, R12, C12,
R21, C21, R22, C22} = G;
G1 = {{{R11, C11}, {R12, C12}},
{{R21, C21}, {R22, C22}}};
PrR1 = 1-PrR2;
PrC1 = 1-PrC2;
UR1 = PrC1*R11+PrC2*R12;
UR2 = PrC1*R21+PrC2*R22;
RUSQ = PrR1*UR1+PrR2*UR2;
UC1 = PrR1*C11+PrR2*C21;
UC2 = PrR1*C12+PrR2*C22;
CUSQ = PrC1*UC1+PrC2*UC2;
(**Define the Darwin map F = .**)
f = PrR2*UR2/RUSQ;
g = PrC2*UC2/CUSQ;
(**Do Eigenvalue analysis at each of the Nash equilibria**)
N0 = Drop[Flatten[Nash[G1]], 1];
N1 = Flatten[Partition[N0, 1, 2]];
NashEquilibria = N[Partition[N1, 2]];
Print["The Nash equilibria of G are: ", NashEquilibria];
EigAnal[X_] := (
Jacob[{PrR2_, PrC2_}] = Outer[D,{f, g},{PrR2, PrC2}];
Print["The Jacobian of the Discrete Darwin Map ",
"at the point ", X, " is ", TableForm[Jacob[X]]];
Eigen = Abs[N[Eigenvalues[Jacob[X]]]];
Print["The Absolute values of the Eigenvalues of the ",
"Jacobian of the Discrete Darwin Map at the point ", X,
" are: ", Eigen];);
Map[EigAnal, NashEquilibria];
);
End[]
EndPackage[]