bnp

Some older Bayesian nonparametrics research.
git clone git://git.jtobin.io/bnp.git
Log | Files | Refs | README | LICENSE

sim_fmm_2d.r (532B)


      1 require(ggplot2)
      2 require(reshape2)
      3 
      4 source('fmm_multivariate_generative.r')
      5 
      6 dimension = 2
      7 
      8 config = list(
      9     k = 4
     10   , l = rep(0, dimension)
     11   , r = diag(0.05, dimension)
     12   , b = dimension
     13   , w = diag(1, dimension)
     14   , n = 10000
     15   )
     16 
     17 set.seed(42)
     18 
     19 d = model(
     20     config$k, config$l, config$r
     21   , config$b, config$w, config$n
     22   )
     23 
     24 framed = lapply(d, function(mat) { data.frame(x = mat[,1], y = mat[,2]) })
     25 melted = melt(framed, id.vars = c('x', 'y'))
     26 
     27 p = ggplot(melted, aes(x, y, colour = factor(L1))) + geom_point(alpha = 0.2)
     28