simulateUCVM | R Documentation |
Simulates 2D correlated velocity movement model
simulateUCVM(nu = 1, tau = 1, v0 = nu * exp((0+1i) * runif(1, 0, 2 * pi)), T.max = NULL, dt = NULL, T = NULL, method = c("direct","exact")[1])
nu |
mean speed of movement |
tau |
characteristic time scale of movement |
v0 |
initial velocity vector. Default is randomly oriented vector with magnitude |
T.max |
maximum time of simulations. |
dt |
time interval of simulations. |
T |
time vector |
method |
one of |
This function simulates an unbiased CVM in one of two ways: either by explicitly sampling from the velocity equation at some small interval dt << tau and integrating to obtain positions, or sampling locations and velocities directly from the true process at arbitrary times.
a list with the following elements
the time vector
the (complex) vector of velocities
the (complex) vector of locations
a 2 x n matrix containing columns for the X and Y coordinates of the location
the parameters of the model.
simulateUCVM, simulateRACVM
# Direct simulation of UCVM nu <- 2; tau <- 5; dt <- .1; ucvm <- simulateUCVM(nu, tau, T.max = 1000, dt = dt) plot(ucvm$XY, asp=1, type="l", main = paste0("UCVM(",nu, tau,")")) ## Also plotting the velocity and using the plot_track function. par(mfrow=c(1,2)) plot(ucvm$V[1:1000], asp=1, type="l", main = "Velocity") plot_track(ucvm$Z[1:1000], pch=19, cex=0.5, col=rgb(0,0,0,.1), main = "Location") # Exact simulation of UCVM, with illustration of velocity and position samples T <- cumsum(rexp(100)) ucvm2 <- simulateUCVM(nu, tau, T = T, method="exact") layout(rbind(c(1,3,3,2), c(1,4,4,2))); par(bty="l", oma=c(0,0,4,0)) with(ucvm2, { plot(V, type="o", asp=1, main="Velocity", col=rgb(0,0,0,.5), cex=0.5) plot(Z, type="o", main="Position", asp=1, col=rgb(0,0,0,.5), cex=0.5) plot(T, Re(V), col=2, type="o", main="Velocity (decomposed)", ylim=range(c(Re(V), Im(V))), pch=19, cex=0.5) lines(T, Im(V), col=3, type="o", pch=19, cex=0.5) plot(T, Re(Z), col=2, type="o", main="Position (decomposed)", ylim=range(XY), pch=19, cex=0.5) lines(T, Im(Z), col=3, type="o", pch=19, cex=0.5) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.