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.

4.3. SIMULATING DISCRETE-TIME MODELS WITH ONE VARIABLE 45simulate <strong>the</strong> progress <strong>of</strong> time as well, as follows (revised parts are marked with ###):Code 4.10: exponential-growth-time.pyfrom pylab import *a = 1.1def initialize():global x, result, t, timesteps ###x = 1.result = [x]t = 0. ###timesteps = [t] ###def observe():global x, result, t, timesteps ###result.append(x)timesteps.append(t) ###def update():global x, result, t, timesteps ###x = a * xt = t + 0.1 ###initialize()while t < 3.: ###update()observe()plot(timesteps, result) ###show()Exercise 4.6Implement a simulation code <strong>of</strong> <strong>the</strong> following difference equation:x t = ax t−1 + b, x 0 = 1 (4.13)This equation is still linear, but now it has a constant term in addition <strong>to</strong> ax t−1 . Somereal-world examples that can be modeled in this equation include fish population

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

Saved successfully!

Ooh no, something went wrong!