Skip to content

Instantly share code, notes, and snippets.

@tpoisot
Created December 21, 2017 19:31
Show Gist options
  • Save tpoisot/f23b3ef6abbeda64f988e9130d52245d to your computer and use it in GitHub Desktop.
Save tpoisot/f23b3ef6abbeda64f988e9130d52245d to your computer and use it in GitHub Desktop.
using Plots
λ = 1.07
K = 50.0
a = 0.06
n = 1.0
ΔN(Nt,Pt) = λ*Nt*exp((1-Nt/K)-a*Pt)
ΔP(Nt,Pt) = n*Nt*(1-exp(-a*Pt))
ΔN(Nt, Pt)
ΔP(Nt, Pt)
t = 9e2
P = zeros(t)
N = zeros(t)
N[1] = 25.0
P[1] = 10.0
for i in 2:length(P)
j = i-1
N[i] = ΔN(N[j], P[j])
P[i] = ΔP(N[j], P[j])
end
p1 = plot(eachindex(N), N, lab="Host", c=:black)
plot!(p1, eachindex(P), P, lab="Parasitoid", c=:red)
xaxis!(p1, "Time")
yaxis!(p1, "Abundances")
p2 = plot(N, P, leg=false, c=:grey)
scatter!(p2, [N[1]], [P[1]], c=:black)
xaxis!(p2, (0, maximum(N)), "Host")
yaxis!(p2, (0, maximum(P)), "Parasitoid")
plot(p1, p2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment