bnp

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

commit 4decc84c210adce3a30022664ad38be30e4dec5d
parent 46aa334c7223b44606f45c906b43287364717a33
Author: Jared Tobin <jared@jtobin.ca>
Date:   Thu, 10 Mar 2016 17:08:33 +1300

Tweak plots (densities -> histograms).

Diffstat:
Mfinite-gaussian-mixture/src/simulation_conditional.r | 25++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/finite-gaussian-mixture/src/simulation_conditional.r b/finite-gaussian-mixture/src/simulation_conditional.r @@ -1,6 +1,7 @@ -set.seed(42) +set.seed(990909) require(ggplot2) +require(gridExtra) require(reshape2) source('fmm_conditional.r') @@ -9,7 +10,7 @@ config = list( k = 3 , a = 1 , l = 0 - , r = 0.1 + , r = 0.01 , b = 1 , w = 1 , n = 1000 @@ -23,6 +24,8 @@ origin = list( d = melt(model(config$k, config$n)) +set.seed(990909) + params = inverse_model( config$n, config$k, d$value , config$a, config$l, config$r @@ -34,8 +37,10 @@ dm = melt(as.data.frame(params$m)) ds = melt(as.data.frame(params$s)) dl = melt(as.data.frame(params$l)) -py = ggplot(d, aes(value, colour = factor(L1), fill = factor(L1))) + - geom_density(alpha = 0.5) +py = ggplot(d, aes(value)) + geom_histogram(alpha = 0.5, fill = 'darkblue') + +py_true = ggplot(d, aes(value, colour = factor(L1), fill = factor(L1))) + + geom_histogram(alpha = 0.5) pp = ggplot(dp, aes(x = seq_along(value), y = value, colour = variable)) + geom_line() @@ -55,13 +60,19 @@ late = data.frame(value = d$value, variable = params$z[config$n - 1,]) p_early = ggplot(early, aes(value, colour = factor(variable), fill = factor(variable))) + - geom_density(alpha = 0.5) + geom_histogram(alpha = 0.5) p_mid = ggplot(mid, aes(value, colour = factor(variable), fill = factor(variable))) + - geom_density(alpha = 0.5) + geom_histogram(alpha = 0.5) p_late = ggplot(late, aes(value, colour = factor(variable), fill = factor(variable))) + - geom_density(alpha = 0.5) + geom_histogram(alpha = 0.5) + +true_plots = grid.arrange(py, py_true, nrow = 2) + +chain_plots = grid.arrange(py, pp, pm, ps, nrow = 2, ncol = 2) + +inferred_plots = grid.arrange(py, p_early, p_mid, p_late, nrow = 2, ncol = 2)