I am following this tutorial on a Lokta Volterra (Predator-prey) problem. I managed to product a plot that looks like theirs. However, I want a definitive proof that my implementation is correct.
My first idea is to calculate rabbits[t]-rabbits[t-1] and compare with the analytical equation of the number of rabbits to see if they are the same. However I cannot make the test code work.
The test code
def test(rabbits, foxes, ts, t):
'''
rabbits, foxes, ts: array of numbers of rabbits, foxes and time points
t: a specific timestep (t < len(ts))
'''
calculated_drabbit_dt=(rabbits[t+1]-rabbits[t])
analytic_drabbit_dt=a*rabbits[t]-b*rabbits[t]*foxes[t] # equation is also in link above, rabbit is called u
print([calculated_drabbit_dt], [analytic_drabbit_dt])
assert np.isclose([calculated_drabbit_dt], [analytic_drabbit_dt])
test(rabbits_2, foxes_2, t, t=166)
Why did I do wrong in my test code?