bnp

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

commit 457c5c5f07e1a5c9b8c5f33878cc46e4f6a71c34
parent 3b8578ffb99acf323ef913d1c0b248331a2bd697
Author: Jared Tobin <jared@jtobin.ca>
Date:   Wed, 24 Feb 2016 15:38:22 +1300

Add HDP.

Diffstat:
Ahierarchical-dirichlet-process/src/hdp.r | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/hierarchical-dirichlet-process/src/hdp.r b/hierarchical-dirichlet-process/src/hdp.r @@ -0,0 +1,15 @@ +BNP_DIR = "/Users/jtobin/projects/bnp" +DP_SRC = paste(BNP_DIR, "dirichlet-process/src/dp.r", sep = "/") + +source(DP_SRC) + +hdp = function(n, a, h, n1, n2, a1, a2) { + g0 = dp(n, a, h) + h0 = function() { sample(g0[[1]], size = 1) } + g1 = dp(n1, a1, h0) + g2 = dp(n1, a1, h0) + h1 = function() { sample(g1[[1]], size = 1) } + h2 = function() { sample(g2[[1]], size = 1) } + list(dp(n2, a2, h1), dp(n2, a2, h2)) + } +