bnp

Some older Bayesian nonparametrics research.
Log | Files | Refs | README | LICENSE

commit 80f818bc63b50b0b46e78872231b1178e93e1ccb
parent 210120e28186da51995324022ac4b13c0706bbc3
Author: Jared Tobin <jared@jtobin.ca>
Date:   Mon, 14 Mar 2016 10:27:20 +1300

Fix multivariate sim code.

Diffstat:
Mfinite-gaussian-mixture/src/simulation_multivariate.r | 33++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/finite-gaussian-mixture/src/simulation_multivariate.r b/finite-gaussian-mixture/src/simulation_multivariate.r @@ -7,34 +7,45 @@ source('fmm_multivariate_generative.r') # 2d config = list( - m = 2 - , v = 2 - , k = 4 + k = 4 + , l = rep(0, 2) + , r = diag(0.05, 2) + , b = 2 + , w = diag(1, 2) , n = 10000 ) set.seed(42) -d = model(config$m, config$k, config$v, config$n) +d = model( + config$k, config$l, config$r + , config$b, config$w, config$n + ) + framed = lapply(d, function(mat) { data.frame(x = mat[,1], y = mat[,2]) }) melted = melt(framed, id.vars = c('x', 'y')) p = ggplot(melted, aes(x, y, colour = factor(L1))) + geom_point(alpha = 0.2) # 3d -set.seed(42) - config_3d = list( - m = 3 - , v = 3 - , k = 4 + k = 4 + , l = rep(0, 3) + , r = diag(0.05, 3) + , b = 3 + , w = diag(1, 3) , n = 10000 ) -d_3d = model(config_3d$m, config_3d$k, config_3d$v, config_3d$n) +set.seed(42) + +d_3d = model( + config_3d$k, config_3d$l, config_3d$r + , config_3d$b, config_3d$w, config_3d$n + ) + framed_3d = lapply(d_3d, function(mat) { data.frame(x = mat[,1], y = mat[,2], z = mat[,3]) }) melted_3d = do.call(rbind, framed_3d) - scatterplot3d(melted_3d, highlight.3d = T, pch = 19)