Skip to content

Instantly share code, notes, and snippets.

@spin-glass
Last active July 29, 2021 12:47
Show Gist options
  • Save spin-glass/83a97aaed112cba5a725581673926d8c to your computer and use it in GitHub Desktop.
Save spin-glass/83a97aaed112cba5a725581673926d8c to your computer and use it in GitHub Desktop.
graphical model of LDA
\documentclass[a4j,12pt,dvipdfmx]{jsarticle}
\usepackage{tikz}
\usepackage[dvipdfmx]{hyperref}
\usetikzlibrary{positioning,fit,arrows.meta}
\begin{document}
\begin{tikzpicture}
\node[draw,circle,minimum size=1cm] (alpha) {$\alpha$};
\node[draw,circle,minimum size=1cm, right=1cm of alpha] (theta) {$\theta_d$};
\node[draw,circle,minimum size=1cm, right=1cm of theta] (z) {$z_{d,i}$};
\node[draw,fill=gray!60,circle,minimum size=1cm, right=1cm of z] (omega) {$\omega_{d,i}$};
\node[draw,circle,minimum size=1cm, right=1cm of omega] (phi) {$\phi_k$};
\node[draw,circle,minimum size=1cm, right=1cm of phi] (beta) {$\beta$};
\draw[-Stealth]
(alpha) edge (theta)
(theta) edge (z)
(z) edge (omega)
(phi) edge (omega)
(beta) edge (phi);
\node[inner sep=0cm,fit={(phi)}] (wrap_phi) {};
\node[inner sep=0cm,below=0.1cm of wrap_phi.south east,anchor=east] (caption_K) {$K$};
\node[draw,rounded corners,fit={(wrap_phi)(caption_K)}] (plate_phi) {};
\node[inner sep=0cm,fit={(z)(omega)}] (wrap_z_omega) {};
\node[inner sep=0cm,below=0.2cm of wrap_z_omega.south east,anchor=east] (caption_n) {$n_d$};
\node[draw,rounded corners,fit={(wrap_z_omega)(caption_n)}] (plate_z_omega) {};
\node[inner sep=0cm,fit={(theta)(plate_z_omega)}] (wrap_theta_z_omega) {};
\node[inner sep=0cm,below=0.2cm of wrap_theta_z_omega.south east,anchor=east] (caption_M) {$M$};
\node[draw,rounded corners,fit={(wrap_theta_z_omega)(caption_M)}] (plate_theta_z_omega) {};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment