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.

10.4. SIMULATION WITHOUT PYCX 183researchers in learning complex systems modeling <strong>and</strong> simulation, so that it eventuallybecomes unnecessary once <strong>the</strong>y have acquired sufficient programming skills.Code 10.11: r<strong>and</strong>om-walk-2D-st<strong>and</strong>alone.pyfrom pylab import *import r<strong>and</strong>om as rdn = 1000 # number <strong>of</strong> particlessd = 0.1 # st<strong>and</strong>ard deviation <strong>of</strong> Gaussian noisedef initialize():global xlist, ylistxlist = []ylist = []for i in xrange(n):xlist.append(rd.gauss(0, 1))ylist.append(rd.gauss(0, 1))def observe():global xlist, ylistcla()plot(xlist, ylist, ’.’)savefig(str(t) + ’.png’)def update():global xlist, ylistfor i in xrange(n):xlist[i] += rd.gauss(0, sd)ylist[i] += rd.gauss(0, sd)t = 0initialize()observe()for t in xrange(1, 100):update()observe()

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

Saved successfully!

Ooh no, something went wrong!