sim_brownian_backward: Simulate reverse-time Brownian motion.

Description Usage Arguments Value See Also Examples

Description

sim_brownian_backward returns a simulated realisation of Brownian motion with known end value and start/end times.

Usage

1
sim_brownian_backward(num_states, fixed_values, times, behavs, variance)

Arguments

num_states

Numeric, number of (behavioural) states that the Brownian motion will simulate over.

fixed_values

List with components:

time

Vector of length one, end time of the simulation.

bearing

Vector of length one, end known value of the simulation.

times

Vector (length variable) of the times at which the brownian motion is to be simulated over (including the start time).

behavs

Vector (length variable but equal to times) of the behaviour/state at each simulation time.

variance

Vector of length num_states, giving the variance of the Brownian motion for each behaviour/state.

Value

Vector (length variable but equal to times) of the simulated Brownian motion (not including known end point).

See Also

Other Brownian motion simulations: sim_brownian_bridge, sim_brownian_forward

Examples

 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
num_states <- 2
fixed_values <- list(time = 10,
                     bearing = 2.3)
times <- seq(0, 10, length.out = 22)[-22]
behavs <- c(rep(1, 6), rep(2, 9), rep(1, 3), rep(2, 3))
variance <- c(0.3, 1.5)

set.seed(123)
sim_brownian_backward(num_states, fixed_values, times, behavs, variance)
# [1] 2.210662 1.998823 1.911824 2.500960 2.527610 2.576476 3.224709 3.614255 2.545083 1.964586
# [11] 1.587933 2.622471 2.926569 3.265283 3.358827 2.889055 3.564445 3.752615 3.009303 3.602057
# [21] 3.202476

num_states <- 2
fixed_values <- list(time = 10,
                     bearing = 2.3)
times <- seq(0, 10, length.out = 22)[-22]
behavs <- rep(1, 21)
variance <- c(0.03, 1.5)

set.seed(2712)
sim_brownian_backward(num_states, fixed_values, times, behavs, variance)
# [1] 2.439727 2.533936 2.586692 2.596769 2.267357 2.350119 2.591627 2.515462 2.531663 2.719289
# [11] 2.697561 2.572232 2.618390 2.619669 2.705751 2.734348 2.720683 2.616551 2.512080 2.555922
# [21] 2.424459

a-parton/CTStepTurn documentation built on May 14, 2019, 4:17 p.m.