bnp

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

commit 2ccab0145f158ad3108791008f5f5babf061fb6a
parent 205bf1b2060f0086bf7a0668a83c4e36e6f4190d
Author: Jared Tobin <jared@jtobin.ca>
Date:   Tue, 23 Feb 2016 17:43:08 +1300

Add gibbs skeleton.

Diffstat:
Mfinite-gaussian-mixture/src/fmm_conditional.r | 28+++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/finite-gaussian-mixture/src/fmm_conditional.r b/finite-gaussian-mixture/src/fmm_conditional.r @@ -2,7 +2,7 @@ set.seed(42) require(dplyr) require(gtools) -require(reshape2) +require(reshape2) # FIXME move to simulation module source('fmm_generative.r') @@ -116,4 +116,30 @@ conditional_precision_model = function(y, z, m, b, w) { mapply(function(a, b) rgamma(1, a, b), a, bet) } +# FIXME errors +inverse_model = function(n, k, y, a, l, r, b, w) { + kernel = function(p, m, s) { + z = conditional_label_model(y, p, m, s) + list( + p = conditional_mixing_model(y, k, z, a) + , mu = conditional_location_model(y, z, s, l, r) + , s = conditional_precision_model(y, z, m, b, w) + ) + } + + p0 = mixing_model(k, a) + m0 = location_model(k, l, r) + s0 = precision_model(k, b, w) + + params = list(p = p0, m = m0, s = s0) + acc = list(p = p0, m = m0, s = s0) + for (j in seq(n)) { + params = kernel(params$p, params$m, params$s) + acc$p = rbind(acc$p, params$p) + acc$m = rbind(acc$m, params$m) + acc$s = rbind(acc$s, params$s) + } + + acc + }