Description Usage Arguments Value Examples
This function extracts a path from a tree.
1 | tree_getpath(tree, n)
|
tree |
is a |
n |
the index of the path to extract. |
This function outputs a matrix of size dimX
by nstep
(see documentation of tree_init
) corresponding to the path indexed by n
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | N = 5
dimX = 2
nstep = 10
#--- Artificially create N particles, each of dimension dimX, evolved for nstep timesteps ---#
X = array(rnorm(N*dimX*(nstep+1)), dim = c(dimX,N,nstep))
a = replicate(nstep-1, sample(1:N, size = N, replace = TRUE))
tree = tree_init(X[,,1])
for (t in 2:nstep){
tree = tree_update(tree, X[,,t], a[,t-1])
}
#--- List all the N final paths ---#
for (i in 1:N){
cat("Path",toString(i),"\n")
print(tree_getpath(tree, i))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.