commit 2b9422c6c0c732fa4f835f17ba4e737512dd0bb7
parent 19189e64bf6f43ce99ff6607055dbfa9a54f68f4
Author: Jared Tobin <jared@jtobin.ca>
Date: Wed, 9 Mar 2016 16:49:08 +1300
Add assignment plots.
Diffstat:
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/finite-gaussian-mixture/src/fmm_conditional.r b/finite-gaussian-mixture/src/fmm_conditional.r
@@ -113,7 +113,8 @@ inverse_model = function(n, k, y, a, l, r, b, w) {
p1 = conditional_mixing_model(y, k, z, a)
m1 = conditional_location_model(y, z, s0, l, r)
s1 = conditional_precision_model(y, z, m1, b, w)
- list(p = p1, m = m1, s = s1, l = lmodel(y, z, p1, m1, s1))
+ l = lmodel(y, z, p1, m1, s1)
+ list(p = p1, m = m1, s = s1, z = z, l = l)
}
p0 = mixing_model(k, a)
@@ -127,6 +128,7 @@ inverse_model = function(n, k, y, a, l, r, b, w) {
acc$p = rbind(acc$p, params$p)
acc$m = rbind(acc$m, params$m)
acc$s = rbind(acc$s, params$s)
+ acc$z = rbind(acc$z, params$z)
acc$l = c(acc$l, params$l)
}
acc
diff --git a/finite-gaussian-mixture/src/simulation_conditional.r b/finite-gaussian-mixture/src/simulation_conditional.r
@@ -49,3 +49,19 @@ ps = ggplot(ds, aes(x = seq_along(value), y = value, colour = variable)) +
pl = ggplot(dl, aes(x = seq_along(value), y = value, colour = variable)) +
geom_line()
+early = data.frame(value = d$value, variable = params$z[1,])
+mid = data.frame(value = d$value, variable = params$z[round(config$n / 2),])
+late = data.frame(value = d$value, variable = params$z[config$n - 1,])
+
+p_early =
+ ggplot(early, aes(value, colour = factor(variable), fill = factor(variable))) +
+ geom_density(alpha = 0.5)
+
+p_mid =
+ ggplot(mid, aes(value, colour = factor(variable), fill = factor(variable))) +
+ geom_density(alpha = 0.5)
+
+p_late =
+ ggplot(late, aes(value, colour = factor(variable), fill = factor(variable))) +
+ geom_density(alpha = 0.5)
+