Description Usage Arguments Value Examples
View source: R/RcppExports.R View source: R/DriftFunctions.R
Use this function to run gillespie simulations. The function is used internally and is not strictly necessary to use directly.
1 | LinearGillespie(numSim, nu, a_mat, x0, time_vec)
|
numSim |
Number of times to run the simulation. The output is the sum of all sims. |
nu |
Matrix with a column per reaction and the same number of rows as states. Each column |
a_mat |
Two column matrix with the same number of rows as reactions. Each row contains first the rate of that reaction and second the |
x0 |
The initial state of the system. |
time_vec |
A vector of time points at which to report the simulation status. Simulate a stochastic process with the Gillespie algorithm. |
A matrix with a column per data point and the same number of rows as states.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # This is the code used to simulate continous labelling
mu = 1e-4
lambda = 0.1
N = 5
Pr = 0.5
time_points = 100:150
numSim = 1e7
beta <- 2*lambda*Pr
alpha <- 2*lambda*(1-Pr)
# Number of chain reactions
M <- N
# Initial state vector
x0 <- c(numSim, rep(0,M))
names(x0) <- paste("x",seq(M+1),sep="")
nu <- matrix(rep(0,(M*(M+1))),ncol=M)
diag(nu) <- -1
diag(nu[2:M,]) <- +1
nu[M+1,M] <- +1
nu <- cbind(nu, -1*nu)
nu <- nu[,-1*c(ncol(nu))]
a_mat <- cbind(c(lambda*N*mu, rep(beta,M-1), rep(alpha,M-1)), c(seq(M),2:M))
sims <- LinearGillespie(numSim=1, nu, a_mat, x0, time_points)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.