commit ca64fcd9ddb108ce2dc849d1d84a47bb30fb7921
parent 1e2922fa9d304cacee179b2385fc3d3bf3aca0d4
Author: Jared Tobin <jared@jtobin.ca>
Date: Thu, 17 Mar 2016 09:22:48 +1300
Add collapsed PGM viz.
Diffstat:
5 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/finite-gaussian-mixture/doc/images/fmm.png b/finite-gaussian-mixture/doc/images/fmm.png
Binary files differ.
diff --git a/finite-gaussian-mixture/doc/images/fmm.tex b/finite-gaussian-mixture/doc/images/fmm.tex
@@ -7,24 +7,26 @@
\begin{tikzpicture}
\tikzstyle{random}=[circle, minimum size = 10mm, thick, draw = black!80, node distance = 16mm]
+ \tikzstyle{observed}=[
+ circle, minimum size = 10mm, thick
+ , draw = black!80, fill = black!10
+ , node distance = 16mm
+ ]
\tikzstyle{connect}=[-latex, thick]
\tikzstyle{plate}=[rectangle, draw = black!100]
\node[random] (p) { $\pi$ };
\node[random] (z) [below of = p] { $z_{i}$ };
- \node[random] (y) [below of = z] { $y_{i}$ };
- \node[random] (mu) [below of = y] { $\mu_{k}$ };
- \node[random] (s) [right of = mu] { $s_{k}$ };
+ \node[observed] (y) [below of = z] { $y_{i}$ };
+ \node[random] (theta) [below of = y] { $\theta_{k}$ };
\path (p) edge [connect] (z)
(z) edge [connect] (y);
- \path (mu) edge [connect] (y);
-
- \path (s) edge [connect] (y);
+ \path (theta) edge [connect] (y);
\node[plate, inner sep = 1.0mm, fit = (z) (y)] { };
- \node[plate, inner sep = 1.0mm, fit = (mu) (s)] { };
+ \node[plate, inner sep = 1.0mm, fit = (theta)] { };
\end{tikzpicture}
diff --git a/finite-gaussian-mixture/doc/images/fmm_collapsed.png b/finite-gaussian-mixture/doc/images/fmm_collapsed.png
Binary files differ.
diff --git a/finite-gaussian-mixture/doc/images/fmm_collapsed.tex b/finite-gaussian-mixture/doc/images/fmm_collapsed.tex
@@ -0,0 +1,31 @@
+\documentclass{standalone}
+\usepackage{tikz}
+\usetikzlibrary{positioning}
+\usetikzlibrary{fit}
+
+\begin{document}
+
+\begin{tikzpicture}
+ \tikzstyle{random}=[
+ circle, minimum size = 10mm, thick
+ , draw = black!80
+ , node distance = 16mm
+ ]
+ \tikzstyle{observed}=[
+ circle, minimum size = 10mm, thick
+ , draw = black!80, fill = black!10
+ , node distance = 16mm
+ ]
+ \tikzstyle{connect}=[-latex, thick]
+ \tikzstyle{plate}=[rectangle, draw = black!100]
+
+ \node[random] (z) { $z_{i}$ };
+ \node[observed] (y) [below of = z] { $y_{i}$ };
+
+ \path (z) edge [connect] (y);
+
+ \node[plate, inner sep = 1.0mm, fit = (z) (y)] { };
+
+\end{tikzpicture}
+
+\end{document}
diff --git a/finite-gaussian-mixture/src/fmm_multivariate_conditional_collapsed.r b/finite-gaussian-mixture/src/fmm_multivariate_conditional_collapsed.r
@@ -50,7 +50,7 @@ conditional_label_model = function(y, k, z, a, l, r, b, w) {
score_by_cluster = function(j) {
sufficient_stats = if (j == old_label) {
- cluster = y_censored[which(z_censored == j), ]
+ cluster = y_censored[which(z_censored == j), ]
sufficient_statistics[[j]] <<- cluster_statistics(cluster, l, b, w)
sufficient_statistics[[j]]
} else {