我正在尝试绘制马尔可夫链图,但无法正确绘制,有人可以帮我吗?转移概率矩阵为:
0 & 1/2 & 1/2 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 \\
1/3 & 1/3 & 0 & 0 & 1/3 & 0 \\
0 & 0 & 0 & 0 & 1/2 & 1/2 \\
0 & 0 & 0 & 1/2 & 0 & 1/2 \\
0 & 0 & 0 & 1 & 0 & 0 \\
答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning,arrows}
\begin{document}
\begin{tikzpicture}[
> = stealth',
auto,
prob/.style = {inner sep=1pt,font=\footnotesize}
]
\node[state] (a) {$a$};
\node[state] (b) [above right=of a] {$b$};
\node[state] (c) [below right=of b] {$c$};
\node[state] (e) [right=of c] {$e$};
\node[state] (d) [above right=of e] {$d$};
\node[state] (f) [below right=of d] {$f$};
\path[->] (a) edge node[prob]{$1/2$} (b)
edge[bend left=10] node[prob]{$1/2$} (c)
(b) edge[loop above] node[prob]{$1$} (b)
(c) edge[bend left=10] node[prob]{$1/3$} (a)
edge node[prob,swap]{$1/3$} (b)
edge node[prob]{$1/3$} (e)
(e) edge[bend left=10] node[prob]{$1/2$} (d)
edge node[prob,swap]{$1/2$} (f)
(d) edge[bend left=10] node[prob]{$1/2$} (e)
edge[bend left=10] node[prob]{$1/2$} (f)
(f) edge[bend left=10] node[prob]{$1$} (d);
\end{tikzpicture}
\end{document}