commit 01fe12fa443c5d8a400bf05cdf7ad909f168766a
parent 2695828332fb86e2c67dd86f2c123a81a10f7e98
Author: Jared Tobin <jared@jtobin.ca>
Date: Sun, 14 Feb 2016 19:17:47 +1300
Finish finite multivariate GMM.
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/finite-gaussian-mixture/src/fmm_multivariate_generative.r b/finite-gaussian-mixture/src/fmm_multivariate_generative.r
@@ -11,8 +11,8 @@ precision_model = function(k, b, w) rinvwishart(k, b, solve(w))
parameter_model = function(m, k, n) {
p = mixing_model(k, 1)
c = delabel(lapply(label_model(n, p), list))
- mu = delabel(apply(location_model(k, rep(0, m), diag(10, m)), MARGIN = 1, list))
- s = precision_model(k, 10, diag(1, m))
+ mu = delabel(apply(location_model(k, rep(0, m), diag(0.05, m)), MARGIN = 1, list))
+ s = precision_model(k, 2, diag(1, m))
list(c, mu, s)
}
@@ -41,3 +41,9 @@ safe_rmvnorm = function(c, m, s) {
else rmvnorm(c, m, solve(s))
}
+# for vis, apply this and then
+# ggplot(foo, aes(x, y, colour = factor(cluster))) + geom_point(alpha = 0.2)
+previs = function(d) {
+ for (j in seq_along(d)) { d[[j]]$cluster = j }
+ do.call(rbind, d)
+ }