simulateUCVM.exact: Correlated velocity movement: Exact Updating

View source: R/simulateUCVM.exact.R

simulateUCVM.exactR Documentation

Correlated velocity movement: Exact Updating

Description

Simulates 2D correlated velocity movement model for arbitrary time intervals, using the "exact" updating formulae of Gillespie (1996).

Usage

simulateUCVM.exact(T, nu = 1, tau = 1, v0 = nu * exp((0+1i) *
runif(1, 0, 2 * pi)))

Arguments

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 nu

Details

This function samples from an unbiased CVM process explicitly using the governing OU equation.

Value

a list with the following elements

T

the time vector

V

the (complex) vector of velocities

Z

the (complex) vector of locations

X

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

dt, tau, nu,vo

the parameters of the model.

See Also

simulateUCVM, simulateRACVM

Examples

# 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)

EliGurarie/smoove documentation built on Aug. 2, 2022, 10:26 p.m.