bnp

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

commit 353f1d88410b9ba30e83f83e24ad7fa14ef6cd20
parent 714f125cb6e56d6d42cbaed512a27fa774003bb4
Author: Jared Tobin <jared@jtobin.ca>
Date:   Sat, 20 Feb 2016 22:58:14 +1300

Use idiomatic do.call.

Diffstat:
Mindian-buffet-process/src/ibp.r | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/indian-buffet-process/src/ibp.r b/indian-buffet-process/src/ibp.r @@ -1,8 +1,10 @@ ibp = function(n, a) { + dishes = max(1, rpois(1, a)) diners = data.frame(dish = seq(dishes), diners = rep(1, dishes)) buffet = list(buffet = diners, choices = list(seq(dishes))) + for (j in seq(n - 1)) { buffet = arrival(buffet, a) } @@ -37,7 +39,7 @@ arrival = function(b, a) { } ibp_matrix = function(buffet) { - dishes = Reduce(max, buffet$choices) + dishes = do.call(max, buffet$choices) index = function(j) { as.numeric(seq(dishes) %in% j) } rows = lapply(buffet$choices, index)