Created
July 11, 2018 15:11
-
-
Save currymj/70ada28a935e4ed5342c368cccf0503b to your computer and use it in GitHub Desktop.
example of bc_model with lag parameter failing for turing inference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DifferentialEquations | |
using DiffEqBayes | |
using Distributions | |
const p0 = 0.2; const q0 = 0.3; const v0 = 1; const d0 = 5 | |
const p1 = 0.2; const q1 = 0.3; const v1 = 1; const d1 = 1 | |
const d2 = 1; const beta0 = 1; const beta1 = 1; #const tau = 1 | |
function bc_model(du,u,h,p,t) | |
du[1] = (v0/(1+beta0*(h(p, t-p[1])[3]^2))) * (p0 - q0)*u[1] - d0*u[1] | |
du[2] = (v0/(1+beta0*(h(p, t-p[1])[3]^2))) * (1 - p0 + q0)*u[1] + | |
(v1/(1+beta1*(h(p, t-p[1])[3]^2))) * (p1 - q1)*u[2] - d1*u[2] | |
du[3] = (v1/(1+beta1*(h(p, t-p[1])[3]^2))) * (1 - p1 + q1)*u[2] - d2*u[3] | |
end | |
h(p, t) = ones(3) | |
tspan = (0.0,10.0) | |
u0 = [1.0,1.0,1.0] | |
prob = DDEProblem(bc_model,u0,h,tspan, [1.0]) | |
alg = MethodOfSteps(RK4()) | |
sol = solve(prob,alg) | |
t_obs = linspace(0.0, 10.0, 1000) | |
randomized = VectorOfArray([sol(t_obs[i]) + 0.01*randn(3) for i=1:length(t_obs)]) | |
data = convert(Array, randomized) | |
turing_result = turing_inference(prob, MethodOfSteps(RK4()), t_obs, data, [Gamma(1.0, 1.0)]; num_samples=500) |
Author
currymj
commented
Jul 11, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment