""" Exercise A.19 from "A primer on..." Implement a scaled version of the logistic growth model, and experiment with different parameter values. """ import numpy as np import matplotlib.pyplot as plt import sys y0 = float(sys.argv[1]) q = float(sys.argv[2]) N = int(sys.argv[3]) y = np.zeros(N + 1) y[0] = y0 for n in range(1, N + 1): y[n] = y[n - 1] + q * y[n-1] * (1-y[n-1]) plt.plot(y) plt.show() """ Terminal> growth_logistic2.py 0.3 1 50 (gives a "well-behaved" plot) Terminal> growth_logistic2.py 0.3 2 50 (gives a plot with oscillates around y=1) Terminal> growth_logistic2.py 0.3 3 50 (plot with more dramatic oscillations) """