View source: R/simulateUCVM.exact.R
simulateUCVM.exact | R Documentation |
Simulates 2D correlated velocity movement model for arbitrary time intervals, using the "exact" updating formulae of Gillespie (1996).
simulateUCVM.exact(T, nu = 1, tau = 1, v0 = nu * exp((0+1i) * runif(1, 0, 2 * pi)))
T |
vector of times |
nu |
mean speed of movement |
tau |
characteristic time scale of movement |
v0 |
initial velocity vector. Default is randomly oriented vector with magnitude |
This function samples from an unbiased CVM process explicitly using the governing OU equation.
a list with the following elements
the time vector
the (complex) vector of velocities
the (complex) vector of locations
a 4xn matrix containing columns for, respectively, Vi, Zi, Vj and Zj where i and j refer to the x and y coordinates of the movement
the parameters of the model.
simulateUCVM, simulateRACVM
# sampling 100 random times up to (about) 1000: T <- cumsum(rexp(100)*10) # Simulate cvm2 <- simulateUCVM.exact(T, nu=2, tau=5) # Illustrate layout(rbind(c(1,3,3,2), c(1,4,4,2))) par(bty="l", oma=c(0,0,4,0)) plot(cvm2$V, type="l", asp=1, main="Velocity", xlab="", ylab="", col="darkgrey") points(cvm2$V, pch=19, cex=0.5) plot(cvm2$Z, type="l", main="Position", asp=1, col="darkgrey") points(cvm2$Z, pch=19, cex=0.5) plot(cvm2$T, Re(cvm2$V), col=2, type="l", main="Velocity (decomposed)", ylim=range(c(Re(cvm2$V), Im(cvm2$V)))) lines(cvm2$T, Im(cvm2$V), col=3, type="l") plot(cvm2$T, Re(cvm2$Z), col=2, type="l", main="Position (decomposed)", ylim=range(c(Re(cvm2$Z), Im(cvm2$Z)))) lines(cvm2$T, Im(cvm2$Z), col=3, type="l") title("CVM(2, 5): 0-1000, 100 random samples", outer=TRUE, cex=1.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.