forked from jluttine/tikz-bayesnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.tex
191 lines (172 loc) · 4.57 KB
/
example.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
% example.tex
%
% Copyright (C) 2010,2011 Laura Dietz
% Copyright (C) 2012 Jaakko Luttinen
%
% The MIT License
%
% See LICENSE file for more details.
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{bayesnet}
%\pgfrealjobname{example} % name of this file
\title{Graphical Models in Tikz}
\author{Laura Dietz, Jaakko Luttinen}
\begin{document}
\maketitle
TikZ examples for graphical models (Bayesian networks) and directed
factor graphs \cite{Dietz:2010}.
% A table of node types
\begin{table}[ht]
\caption{Node types}
\begin{center}
\begin{tabular}{llc}
Type & Syntax & Output
\\
\hline
Latent variable &
\texttt{\textbackslash node[latent]} &
\tikz{ %
\node[latent] {$x$}; %
}
\\
Observed variable &
\texttt{\textbackslash node[obs]} &
\tikz{ %
\node[obs] {$y$}; %
}
\\
Deterministic &
\texttt{\textbackslash node[det]} &
\tikz{ %
\node[det] {dot} ; %
}
\\
Constant &
\texttt{\textbackslash node[const]} &
\tikz{ %
\node[const] {$a$}; %
}
\\
Factor &
\texttt{\textbackslash node[factor]} &
\tikz{ %
\node[factor] [label=$\mathcal{N}$] {}; %
}
\end{tabular}
\end{center}
\end{table}
\begin{table}[ht]
\caption{Edge types}
\begin{center}
\begin{tabular}{llc}
Type & Syntax & Output
\\
\hline
Directed edges &
\texttt{\textbackslash edge[opts]\{inputs\}\{outputs\}} &
\tikz{ %
\node[obs] (y) {$y$} ; %
\node[latent, left=of y, yshift=0.5cm] (mu) {$\mu$} ; %
\node[latent, left=of y, yshift=-0.5cm] (tau) {$\tau$} ; %
\edge {mu,tau} {y} ; %
}
\\
Undirected edges &
\texttt{\textbackslash edge[-,opts]\{inputs\}\{outputs\}} &
\tikz{ %
\node[obs] (y) {$y$} ; %
\node[latent, left=of y, yshift=0.5cm] (mu) {$\mu$} ; %
\node[latent, left=of y, yshift=-0.5cm] (tau) {$\tau$} ; %
\edge[-] {mu,tau} {y} ; %
}
\\
Factor graph edges &
\texttt{\textbackslash factoredge[opts]\{inputs\}\{via\}\{outputs\}} &
\tikz{ %
\node[obs] (y) {$y$} ; %
\node[latent, left=of y, yshift=0.5cm] (mu) {$\mu$} ; %
\node[latent, left=of y, yshift=-0.5cm] (tau) {$\tau$} ; %
\factor[left=of y] {y-factor} {$\mathcal{N}$} {} {};
\factoredge {mu,tau} {y-factor} {y} ; %
}
\end{tabular}
\end{center}
\end{table}
\begin{table}[ht]
\caption{Utilities}
\begin{center}
\begin{tabular}{llc}
Type & Syntax & Output
\\
\hline
Plate &
\texttt{\textbackslash plate} &
\tikz{ %
\node[latent] (x) {$x_m$}; %
\plate {} {(x)} {$m \in \mathcal{M}$}; %
}
\\
Gate &
&
\tikz{
% Nodes
\node[obs] (k) {$k$}; %
\node[latent, above=2 of k] (l) {$\lambda$}; %
\factor[above=0.8 of k] {k-f} {Multi} {} {}; %
\node[latent, right=of k-f] (paa) {$\phi$}; %
%\node[latent, right=of k-f] (p) {$\phi$}; %
% Connections
\factoredge {paa} {k-f} {k} ; %
% Gate
\gate {} {(k-f)(k-f-caption)} {l} ; %
}
\end{tabular}
\end{center}
\end{table}
% Simple Bayesian network
\begin{figure}[ht]
\begin{center}
\begin{tabular}{cc}
\input{model_pca} &
\input{model_pca2}
\end{tabular}
\end{center}
\caption{PCA model as a Bayesian network and a directed factor
graph.}
\end{figure}
% Latent Dirichlet allocation
\begin{figure}[ht]
\begin{center}
\input{model_lda}
\end{center}
\caption{Latent Dirichlet allocation as directed factor graph.}
\end{figure}
% Citation influence model
\begin{figure}[ht]
\begin{center}
\input{model_citation_influence}
\end{center}
\caption{Citation influence model with own topics \cite{Dietz:2007}
as directed factor graph.}
\end{figure}
\clearpage
\begin{thebibliography}{9}
\bibitem{Dietz:2010}
Laura Dietz,
\emph{Directed Factor Graph Notation for Generative Models}.
Technical Report. 2010
% Laura Dietz, Steffen Bickel, Tobias Scheffer.
% Unsupervised Prediction of Citation Influences.
% In: Proceedings of International Conference on Machine Learning. 2007
\bibitem{Dietz:2007}
Laura Dietz, Steffen Bickel, Tobias Scheffer,
\emph{Unsupervised Prediction of Citation Influences}.
In: Proceedings of International Conference on Machine
Learning. 2007
\end{thebibliography}
\end{document}
%%% Local Variables:
%%% mode: tex-pdf
%%% TeX-master: t
%%% End: