bnp

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

hdp.r (457B)


      1 BNP_DIR = "/Users/jtobin/projects/bnp"
      2 DP_SRC  = paste(BNP_DIR, "dirichlet-process/src/dp.r", sep = "/")
      3 
      4 source(DP_SRC)
      5 
      6 # FIXME (jtobin): this may not be correct
      7 hdp = function(n, a, h, n1, n2, a1, a2) {
      8   g0 = dp(n, a, h)
      9   h0 = function() { sample(g0[[1]], size = 1) }
     10   g1 = dp(n1, a1, h0)
     11   g2 = dp(n1, a1, h0)
     12   h1 = function() { sample(g1[[1]], size = 1) }
     13   h2 = function() { sample(g2[[1]], size = 1) }
     14   list(dp(n2, a2, h1), dp(n2, a2, h2))
     15   }
     16