commit 29f9e4a3e7513a3fae8d1c152cce2717a31a5bdd
parent 2e8a32407c02d2d260cace4d8981094e7a7f0a17
Author: Jared Tobin <jared@jtobin.ca>
Date: Wed, 24 Feb 2016 15:21:54 +1300
Add Dirichlet process.
Diffstat:
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/dirichlet-process/src/dp.r b/dirichlet-process/src/dp.r
@@ -0,0 +1,15 @@
+BNP_DIR = "/Users/jtobin/projects/bnp"
+SBP_SRC = paste(BNP_DIR, "stick-breaking-process/src/sbp.r", sep = "/")
+
+source(SBP_SRC)
+
+# ex: gaussian base measure
+#
+# > dp(10, 1, function() { rnorm(1) })
+dp = function(n, a, h) {
+ p = sbp(n - 1, a)
+ g = replicate(length(p), h())
+ list(p, g)
+ }
+
+