A Base R, simple implementation of the No-Underrun Sampler. This package aims to mostly directly implement the algorithm as described by th
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Special two arg log_sum

+9 -1
+9 -1
R/NURS.R
··· 8 8 } 9 9 } 10 10 11 + log_sum_two <- function(log_a, log_b) { 12 + if (log_a > log_b) { 13 + log_a + log1p(exp(log_b - log_a)) 14 + } else { 15 + log_b + log1p(exp(log_a - log_b)) 16 + } 17 + } 18 + 11 19 #' Check no underrun stopping condition 12 20 #' 13 21 #' @param log_vals orbit ··· 85 93 for (i in seq_len(n_ext)) { 86 94 theta_i <- orbit_ext[[i]] 87 95 log_i <- log_ext[i] 88 - logW_new <- log_sum_exp(c(logW, log_i)) 96 + logW_new <- log_sum_two(logW, log_i) 89 97 if (runif(1) < exp(log_i - logW_new)) theta_tilde <- theta_i 90 98 logW <- logW_new 91 99 }