1

enter image description here

How can I draw this figure about Hidden Markov Model?

  • 3
    Welcome to TeX.SE! Please show us the code you have tried so far ... – Mensch Jul 6 at 0:48
8

For exercise (how to draw dashed line and use empty cells):

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{tikz-cd}
\usepackage{amsmath}

\begin{document}
\begin{tikzcd}[nodes in empty cells]  
X_1 \ar[r, "A"] \ar[dd, "B"'] 
    &   X_2 \ar[r, "A"] \ar[dd, "B"']  
        &   X_3 \ar[r, "A"] \ar[dd, "B"']  
            &   \dots  \ar[r, "A"] 
                &   X_{T-1} \ar[dd, "B"']       \\
\arrow[rrrr, dashed, -,  
       start anchor={[shift={(-3ex,2ex)}]north west},
       end anchor  ={[shift={( 3ex,2ex)}]north east}]
    &   &   &   &                               \\
    &   &   &   \dotsm  &
\end{tikzcd}
\end{document}

Complete reproduction of presented images:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz-cd}
\usepackage{amsmath}

\begin{document}
\begin{tikzcd}[nodes in empty cells]
\text{Markov process:}
    &   X_0 \ar[r, "A"] \ar[dd, "B"']
        &   X_1 \ar[r, "A"] \ar[dd, "B"']
            &   X_2 \ar[r, "A"] \ar[dd, "B"']
                &   \dots  \ar[r, "A"]
                    &   X_{T-1} \ar[dd, "B"']       \\
    &   \arrow[rrrr, dashed, -,
           start anchor={[shift={(-3ex,2ex)}]north west},
           end anchor  ={[shift={( 3ex,2ex)}]north east}]
    &   &   &   &   &                               \\
\text{Observations:}
    &   \mathcal{O}_0
        &   \mathcal{O}_1
            &   \mathcal{O}_2
                &   \dotsm
                    &   \mathcal{O}_{T-1}           \\
\end{tikzcd}
\end{document}

enter image description here

3

With a normal matrix of math nodes.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{amsmath}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of math nodes,column sep=2em,row sep=4em] (m) {
\text{Markov process}: &
 X_0 & X_1 & X_2 & \cdots & X_{T-1}\\
\text{Observations}: & 
 \mathcal{O}_0 & \mathcal{O}_1 & \mathcal{O}_2 & \cdots & \mathcal{O}_{T-1}\\
};
\foreach \X in {2,3,4,5}
{\draw[-latex] (m-1-\X) -- (m-1-\the\numexpr\X+1) node[midway,above]{$A$};
\ifnum\X=5
\draw[-latex] (m-1-6) -- (m-2-6) node[pos=0.6,left]{$B$};
\else
\draw[-latex] (m-1-\X) -- (m-2-\X) node[pos=0.6,left]{$B$};
\fi}
\draw[dashed] ([yshift=1ex]m.east) -- ([yshift=1ex]m.east-|m-1-1.east);
\end{tikzpicture}
\end{document}

enter image description here

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.