Created
March 15, 2021 21:31
-
-
Save lefuturiste/cd0d8ea99f9f2de201817a3e3587b138 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import numpy as np | |
from scipy.integrate import odeint | |
import matplotlib.pyplot as plt | |
t = np.arange(0, 15, 0.1) | |
a = 0.5 | |
b = 0.5 | |
def tick(y, t): | |
rabbits, foxes = y | |
return [ | |
rabbits-a*rabbits*foxes, | |
-foxes+b*rabbits*foxes | |
] | |
sol = odeint(tick, [1, 1], t) | |
plt.plot(t, sol[:, 0], 'b', label='rabbits(t)') | |
plt.plot(t, sol[:, 1], 'g', label='foxes(t)') | |
plt.legend(loc='best') | |
plt.xlabel('t') | |
plt.grid() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment