15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.3. SIMULATING DISCRETE-TIME MODELS WITH ONE VARIABLE 43Code 4.7:from pylab import *And <strong>the</strong>n you can add <strong>the</strong> following lines <strong>to</strong> <strong>the</strong> end <strong>of</strong> your code:Code 4.8:plot(result)show()The completed code as a whole is as follows (you can download <strong>the</strong> actual Python codeby clicking on <strong>the</strong> name <strong>of</strong> <strong>the</strong> code in this textbook):Code 4.9: exponential-growth.pyfrom pylab import *a = 1.1def initialize():global x, resultx = 1.result = [x]def observe():global x, resultresult.append(x)def update():global x, resultx = a * xinitialize()for t in xrange(30):update()observe()plot(result)show()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!