Skip to content

Instantly share code, notes, and snippets.

@transientlunatic
Created March 17, 2019 09:54
Show Gist options
  • Save transientlunatic/dbb3f5151e83777bb9194ec3f0e8211a to your computer and use it in GitHub Desktop.
Save transientlunatic/dbb3f5151e83777bb9194ec3f0e8211a to your computer and use it in GitHub Desktop.
Markov chain illustration in LaTeX
\newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}
\newcommand\complicated{ 0.5*( 1/(.2*sqrt(2*pi))*exp(-((x-1)^2)/(.2*2^2))) + 0.5*(1/(.5*sqrt(2*pi))*exp(-((x-5)^2)/(.5*2^2)) ) }
% Gauss function, parameters mu and sigma
\begin{tikzpicture}
\foreach \x in {1,2,...,4}{
\begin{scope}[xshift=1cm, yshift=1.5*\x cm]
\begin{axis}[every axis plot post/.append style={
mark=none,domain=-3:8,samples=50,smooth},
clip=false,
xscale=0.3,
yscale=0.2,
axis y line=none,
axis x line=none,
ymin=0,
xtick=\empty,
]
\addplot[thick]{0.5*\complicated};
\addplot[dashed] {0.5*\gauss{0}{1}};
\node (x1) [text badly centered] at (axis cs:1,-0.1) {\tiny{$x_1$}};
\end{axis}
\end{scope}
\begin{scope}[yshift=1.5*\x cm]
\node (initial) [draw, circle] {$x_1$};
\end{scope}
};
\end{tikzpicture}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment