成功运行马尔可夫链图

成功运行马尔可夫链图

我正在尝试绘制一个马尔可夫链转换图来显示成功运行,如下所示: 在此处输入图片描述

然而,与上面的图片相比,我自己的尝试看起来相当丑陋:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}


\begin{document}
\begin{tikzpicture}
    [%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        node distance =.8cm,
        place/.style={rectangle,draw=blue!50,fill=blue!20,thick,
                      inner sep=0pt,minimum size=6mm}
    ]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node[place] (1) {$0$};
\node[place] (2) [right=of 1] {$1$};
\node[place] (3) [right=of 2] {$2$};
\node[place] (4) [right=of 3] {$3$};
\node[text] (5) [right=of 4] {$\cdots\cdots$};
\node[place] (6) [right=of 5] {$2021$};
\node[text] (7) [right=of 6] {$\cdots$};

\draw [->,thick] (1.south west) to [bend left=55]  node[left]  {1}    (1.north west);
\draw [->,thick] (1.north east) to [bend left=15]  node[above] {$P_0$}  (2.north west);
\draw [->,thick] (2.north east) to [bend left=15]  node[above] {$P_1$}  (3.north west);
\draw [->,thick] (3.north east) to [bend left=15]  node[above] {$P_2$}  (4.north west);
\draw [->,thick] (4.north east) to [bend left=15]  node[above] {$P_3$} (5.north west);
\draw [->,thick] (5.north east) to [bend left=15]  node[above] {$P_{2020}$} (6.north west);
\draw [->,thick] (6.north east) to [bend left=15]  node[above] {$P_{2021}$} (7.north west);
\draw [<-,thick] (1.south east) to [bend right=15] node[below] {$1-P_3$} (4.south west);
\draw [<-,thick] (1.south east) to [bend right=15] node[below] {$1-P_2$}  (3.south west);
    
\end{tikzpicture}
\end{document}

在此处输入图片描述

带有重叠箭头等。关于复制第一个图表,有什么建议吗?

答案1

在此处输入图片描述

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{automata}
\usetikzlibrary{positioning}  %                 ...positioning nodes
\usetikzlibrary{arrows}       %                 ...customizing arrows
\tikzset{node distance=1cm, % Minimum distance between two nodes. Change if necessary.
         every state/.style={ % Sets the properties for each state
           semithick,draw=blue!50,
           fill=blue!20},
         initial text={},     % No label on start arrow
         double distance=4pt, % Adjust appearance of accept states
         every edge/.style={  % Sets the properties for each transition
         draw, ->,>=stealth',     % Makes edges directed with bold arrowheads
           auto, thick},
}
\begin{document}
\begin{tikzpicture}
   
\node[state] (1) {$0$};
\node[state] (2) [right=of 1] {$1$};
\node[state] (3) [right=of 2] {$2$};
\node[state] (4) [right=of 3] {$3$};
\node[] (5) [right=of 4] {$\cdots\cdots$};
\node[state] (6) [right=of 5] {$2021$};
\node[] (7) [right=of 6] {$\cdots$};

\path (1) edge[loop left]  node{$1-p_0$} (1);
% \draw [->,thick] (1.south west) to [bend left=55]  node[left]  {1}    (1.north west);
\draw [->,thick] (1.north east) to [bend left=55]  node[above] {$P_0$}  (2.north west);
\draw [->,thick] (2.north east) to [bend left=55]  node[above] {$P_1$}  (3.north west);
\draw [->,thick] (3.north east) to [bend left=55]  node[above] {$P_2$}  (4.north west);
\draw [->,thick] (4.north east) to [bend left=55]  node[above] {$P_3$} (5.north west);
\draw [->,thick] (5.north east) to [bend left=55]  node[above] {$P_{2020}$} (6.north west);
\draw [->,thick] (6.north east) to [bend left=55]  node[above] {$P_{2021}$} (7.north west);
\draw [<-,thick] (1.south east) to [bend right=55] node[pos=0.5, below] {$1-P_3$} (4.south west);
\draw [<-,thick] (1.south east) to [bend right=55] node[pos=0.8, below=4pt] {$1-P_2$}  (3.south west);
    
\end{tikzpicture}
\end{document}

相关内容