Question: We now provide you with code for simulating the model above ( see below ) . This consists of two functions, which you can inspect
We now provide you with code for simulating the model above
see below
This consists of two functions, which you can inspect below. All can be seen in the live docs. Read them to help answer the remainder of question
which is situated below the code.
parameterise
basic
model
solve
We also provide a variable data, that provides noisy data on the predator and prey populations taken by a biologist...
data
:
contains the timepoints
measured in years
over which the data was taken
data
:
represents the estimated prey population
measured in hundreds, i
e
data
means
estimated animals at timepoint
over these timepoints
data
:
represents the predator population over these timepoints, measured in tens.
times
Matrix
Float
:
solve
f::Function, tspan, x
::Vector
Numerically solves the ODE x
t
f
x
t
t
on the timespan whose start
end points are enclosed in tspan. Recall that x
denotes the time derivative of x
t
i
e
dx
dt
Example
solve
f
solves between t
and t
using initial conditions x
e
How would the basic model change if we instead measured predators and prey in units of a single animal?
Hint: take
and
Can you rewrite the differential equation in terms of these two variables instead, using the chain rule?
f
Build a function simulation
p
It must take in a vector of
parameters
e
g
simulation
It must output a
times
matrix holding the solution of the differential equation: i
e
the populations of prey
st column
and predators
nd column
over the timepoints range
step
The initial conditions can be
g
