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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.2. PHASE SPACE VISUALIZATION OF CONTINUOUS-STATE DISCRETE-TIME... 63For discrete-time systems with continuous-state variables (i.e., state variables thattake real values), drawing a phase space can be done very easily using straightforwardcomputer simulations, just like we did in Fig. 4.3. To reveal a large-scale structure <strong>of</strong> <strong>the</strong>phase space, however, you will probably need <strong>to</strong> draw many simulation results startingfrom different initial states. This can be achieved by modifying <strong>the</strong> initialization functionso that it can receive specific initial values for state variables, <strong>and</strong> <strong>the</strong>n you can put <strong>the</strong>simulation code in<strong>to</strong> for loops that sweep <strong>the</strong> parameter values for a given range. Forexample:Code 5.1: phasespace-drawing.pyfrom pylab import *def initialize(x0, y0): ###global x, y, xresult, yresultx = x0 ###y = y0 ###xresult = [x]yresult = [y]def observe():global x, y, xresult, yresultxresult.append(x)yresult.append(y)def update():global x, y, xresult, yresultnextx = 0.5 * x + ynexty = -0.5 * x + yx, y = nextx, nextyfor x0 in arange(-2, 2, .5): ###for y0 in arange(-2, 2, .5): ###initialize(x0, y0) ###for t in xrange(30):update()observe()plot(xresult, yresult, ’b’) ###

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

Saved successfully!

Ooh no, something went wrong!