博弈论:带箭头的收益矩阵

博弈论:带箭头的收益矩阵

基于策略/收益矩阵我想添加箭头来表示均衡;这样

在此处输入图片描述

变成这样

在此处输入图片描述

如有任何建议,我们将不胜感激。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}

\matrix[matrix of math nodes,every odd row/.style={align=right},every even row/.style={align=left},every node/.style={text width=1.5cm},row sep=0.2cm,column sep=0.2cm] (m) {
    10&5\\
    10&25\\
    5&20\\
    25&20\\
};
\draw (m.north east) rectangle (m.south west);
\draw (m.north) -- (m.south);
\draw (m.east) -- (m.west);

\coordinate (a) at ($(m.north west)!0.25!(m.north east)$);
\coordinate (b) at ($(m.north west)!0.75!(m.north east)$);
\node[above=5pt of a,anchor=base] {Low Price};
\node[above=5pt of b,anchor=base] {High Price};

\coordinate (c) at ($(m.north west)!0.25!(m.south west)$);
\coordinate (d) at ($(m.north west)!0.75!(m.south west)$);
\node[left=2pt of c,text width=1cm]  {Low Price};
\node[left=2pt of d,text width=1cm]  {High Price};

\node[above=18pt of m.north] (firm b) {Firm B};
\node[left=1.6cm of m.west,rotate=90,align=center,anchor=center] {Firm A};

\node[above=5pt of firm b]  {Payoff Matrix};
\end{tikzpicture}

\end{document}

答案1

我引用我之前的帖子特克斯世界回答问题游戏理论分配矩阵与均衡分布

仅使用引用矩阵元素的绘图命令的快速解决方案:

\draw [-latex, blue, very thick]
    (m-1-2.center) edge (m-1-1)
    ($(m-2-1.south)+(-0.55,0)$) edge ($(m-4-1.north)+(-0.55,0)$)
    (m-3-1.east) edge (m-3-2.center)
    ($(m-4-2.north)+(-0.55,0)$) to ($(m-2-2.south)+(-0.55,0)$);
\end{tikzpicture}

您可以调整计算值。我需要计算,因为每行的对齐方式不同。我更希望列数增加一倍,但对齐方式保持一致,以便于参考。

上面的几行给出了原始代码:

收益矩阵

答案2

首先,我将只展示矩阵部分。然后查看答案末尾的完整解决方案。

这是一个简单的tabular解决方案,带有一些重叠和堆叠。我引入了\LA\RA\DA\UA来表示左、右、下和上箭头;以及\Under{<number>}{<arrow>}来表示在给定数字下放置上/下箭头。由于表格是右对齐的,因此放置了左箭头和右箭头数据输入以实现正确对齐。

\documentclass{article}
\usepackage{graphicx}
\usepackage{stackengine}
\newcommand\Under[2]{\strut\smash{\stackunder{#1}{#2}}}
\setstackgap{L}{1.1\normalbaselineskip}
\setstackgap{S}{2pt}
\def\LA{\rlap{\scalebox{2.8}[1.5]{\kern2pt\raisebox{-.5pt}{$\leftarrow$}}}}
\def\RA{\rlap{\scalebox{2.8}[1.5]{\kern2pt\raisebox{-.5pt}{$\rightarrow$}}}}
\def\UA{\tclap{\scalebox{1.5}[2.8]{$\uparrow$}}}
\def\DA{\bclap{\scalebox{1.5}[2.8]{$\downarrow$}}}
\renewcommand\arraystretch{1.5}
\begin{document}
\begin{tabular}{|rr|rr|}
\hline
&10\LA&&5\\
\Under{10}{\DA}&&\Under{25}{\UA}&\\
\hline
&5\RA&&20\\
25&&20&\\
\hline
\end{tabular}
\end{document}

在此处输入图片描述

对于完整的解决方案,

\documentclass{article}
\usepackage{graphicx}
\usepackage{stackengine}
\newcommand\Under[2]{\strut%
  \setstackgap{L}{1.1\normalbaselineskip}%
  \setstackgap{S}{2pt}%
  \smash{\stackunder{#1}{#2}}%
}
\def\LA{\rlap{\scalebox{2.8}[1.5]{\kern2pt\raisebox{-.5pt}{$\leftarrow$}}}}
\def\RA{\rlap{\scalebox{2.8}[1.5]{\kern2pt\raisebox{-.5pt}{$\rightarrow$}}}}
\def\UA{\tclap{\scalebox{1.5}[2.8]{$\uparrow$}}}
\def\DA{\bclap{\scalebox{1.5}[2.8]{$\downarrow$}}}
\renewcommand\arraystretch{1.5}
\begin{document}
\raisebox{-15pt}{\rotatebox{90}{Firm A}}~~
{\small\stackanchor[14pt]{\Longstack{High Price}}{\Longstack{Low Price}}}
\stackon{%
\begin{tabular}{|rr|rr|}
\hline
&10\LA&&5\\
\Under{10}{\DA}&&\Under{25}{\UA}&\\
\hline
&5\RA&&20\\
25&&20&\\
\hline
\end{tabular}%
}{\stackon[12pt]{\stackon[8pt]{\small Low Price High Price}{Firm B}}{Payoff Matrix}}
\end{document}

在此处输入图片描述

答案3

PSTricks 解决方案:

\documentclass{article}

\usepackage{pstricks-add}

\newcommand*\stack[2]{\shortstack[l]{#1\strut\\ #2\strut}}

\begin{document}

\begin{pspicture}(0.18,0)(6,4.95)
  \psframe(2,0)(6,3)
  \psline(4,0)(4,3)
  \psline(2,1.5)(6,1.5)
  \uput[180](2,0.75){\stack{High}{Price}}
  \uput[180](2,2.25){\stack{Low}{Price}}
  \rput(1,1.1){\psrotate(0,0){90}{Firm~A}}
  \uput[90](3,3){Low Price}
  \uput[90](5,3){High Price}
  \rput(4,4.1){Firm~B}
  \rput(4,4.8){Payoff Matrix}
  \uput[45](2,0){$25$}
  \uput[225](4,1.5){$5$}
  \uput[45](2,1.5){$10$}
  \uput[225](4,3){$10$}
  \uput[45](4,1.5){$25$}
  \uput[225](6,3){$5$}
  \uput[45](4,0){$20$}
  \uput[225](6,1.5){$20$}
 \psset{arrows = ->, linecolor = blue!70}
  \psline(2.3,1.55)(2.3,0.4)
  \psline(4.3,0.4)(4.3,1.55)
  \psline(3.92,1.25)(5.5,1.25)
  \psline(3.92,2.75)(5.65,2.75)
\end{pspicture}

\end{document}

输出

相关内容