Description Usage Arguments References Examples
Implementation of backwards sampling algorithm described in Appendix A of Rao and Teh (2013).
1 | bs(a, B, L)
|
a |
collection of forward filtering distributions |
B |
collection of uniformized single-step transition matrices |
L |
likelihood matrix where each column is the probability distribution for the state at each of the discrete transitions |
Rao, Vinayak, and Yee Whye Teh. "Fast MCMC sampling for Markov jump processes and extensions." The Journal of Machine Learning Research 14.1 (2013): 3295-3320.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | data('dive.sim')
attach(dive.sim)
attach(dive.sim$params)
# uniformized transition rate
r.unif = max(outer(lambda, 2 * depth.bins$halfwidth, '/'))
# single-step transition matrix
m = dsdive.tx.matrix.uniformized(depth.bins = depth.bins, beta = beta,
lambda = lambda, s0 = 2,
rate.uniformized = r.unif)
# number of states
k = nrow(m)
# number of transitions
N = 10
# list of transition matrices
B = lapply(1:N, function(i) m)
# starting and ending coordinates
x0 = 5
xN = 10
# encode likelihood information
L = matrix(0, nrow = k, ncol = N+1)
L[x0,1] = 1 # fixed starting location
L[xN,N+1] = 1 # fixed ending location
L[,-c(1,N+1)] = 1/k # free transitions
L[x0,2] = 0 # force a transition by 2nd step
L = sweep(L, 2, colSums(L), '/') # restandardize likelihood
# forward filter
a = ff(B = B, L = L)
# backwards sample
set.seed(2019)
y = bs(a = a, B = B, L = L)
# execute forward filtering and backwards sampling via wrapper
set.seed(2019)
x = ffbs(B = B, L = L)
# sampling steps are identical
identical(x,y)
detach(dive.sim$params)
detach(dive.sim)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.