2010-03-08 851-0585-04l – modelling and simulating social systems with matlab © eth zürich |...
TRANSCRIPT
![Page 1: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/1.jpg)
2010-03-08
851-0585-04L – Modelling and Simulating Social Systems with MATLAB
© ETH Zürich |
Lesson 3 – Dynamical Systems
Anders Johansson and Wenjian Yu
![Page 2: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/2.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 2
Projects
Implementation of a model from the Social-Science literature in MATLAB.
Carried out in pairs. The projects will be assigned next week:
March 15, 2010
![Page 3: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/3.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 3
Lesson 3 - Contents
Differential Equations
Dynamical Systems Pendulum Lorenz attractor Lotka-Volterra equations Epidemics: Kermack-McKendrick model
Exercises
![Page 4: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/4.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 4
Differential equations
Solving differential equations numerically can be
done by a number of schemes. The easiest way
is by the 1st order Euler’s Method:
,..)( )()(
,...)()()(
,...)(
xftttxtx
xft
ttxtx
xfdt
dx
t
x
Δt
x(t)
x(t-Δt)
![Page 5: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/5.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 5
Dynamical systems
A dynamical system is a mathematical description
of the time dependence of a point in a space.
A dynamical system is described by a set of
linear/non-linear differential equations.
Even though an analytical treatment of dynamical
systems is often complicated, obtaining a
numerical solution is straight forward.
![Page 6: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/6.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 6
Pendulum
A pendulum is a simple dynamical system:
L = length of pendulum (m)
ϴ = angle of pendulum
g = acceleration due to
gravity (m/s2)
The motion is described by:
)sin(L
g
![Page 10: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/10.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 10
Set starting point of pendulum
![Page 11: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/11.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 11
Time loop: Simulate the pendulum
![Page 12: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/12.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 12
Perform 1st order Euler’s method
![Page 16: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/16.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 16
Pendulum: Executing MATLAB code
![Page 17: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/17.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 17
Lorenz attractor
The Lorenz attractor defines a 3-dimensional
trajectory by the differential equations:
σ, r, b are parameters. bzxydt
dz
xzyrxdt
dy
yxdt
dx
)(
![Page 18: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/18.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 18
Lorenz attractor: MATLAB code
![Page 23: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/23.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 23
Solve the Lorenz-attractor equations
![Page 25: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/25.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 25
Perform 1st order Euler’s method
![Page 29: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/29.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 29
![Page 31: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/31.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 31
Lotka-Volterra equations
The Lotka-Volterra equations describe the
interaction between two species, prey vs.
predators, e.g. rabbits vs. foxes.
x: number of prey
y: number of predators
α, β, γ, δ: parameters)(
)(
xydt
dy
yxdt
dx
![Page 32: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/32.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 32
Lotka-Volterra equations
The Lotka-Volterra equations describe the
interaction between two species, prey vs.
predators, e.g. rabbits vs. foxes.
![Page 33: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/33.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 33
Lotka-Volterra equations
The Lotka-Volterra equations describe the
interaction between two species, prey vs.
predators, e.g. rabbits vs. foxes.
![Page 34: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/34.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected]
Epidemics
34
Source: Balcan, et al. 2009
![Page 35: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/35.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 35
SIR model
A model for epidemics is the SIR model, which
describes the interaction between Susceptible,
Infected and Removed (immune) persons, for a
given disease.
![Page 36: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/36.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 36
Kermack-McKendrick model
of diseases like the plague and cholera. A
popular SIR model is the Kermack-McKendrick
model. The model was proposed for explaining
the spreading
The model assumes: A constant population size. A zero incubation period. The duration of infectivity is as long as the duration of
the clinical disease.
![Page 37: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/37.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 37
Kermack-McKendrick model
The Kermack-McKendrick model is specified as:
S: Susceptible persons
I: Infected persons
R: Removed (immune)
persons
β: Infection rate
γ: Immunity rate
S
IR
β transmission
γrecovery
![Page 38: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/38.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 38
Kermack-McKendrick model
The Kermack-McKendrick model is specified as:
S: Susceptible persons
I: Infected persons
R: Removed (immune)
persons
β: Infection rate
γ: Immunity rate )(
)( )()(
)()(
tIdt
dR
tItStIdt
dI
tStIdt
dS
![Page 39: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/39.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 39
Kermack-McKendrick model
The Kermack-McKendrick model is specified as:
S: Susceptible persons
I: Infected persons
R: Removed (immune)
persons
β: Infection rate
γ: Immunity rate
![Page 40: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/40.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 40
Exercise 1 Implement and simulate the Kermack-McKendrick model in MATLAB.
Use the starting values:
S=I=500, R=0, β=0.0001, γ =0.01
Slides/exercises: www.soms.ethz.ch/matlab
(Download only possible with Firefox!)
![Page 41: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/41.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 41
Exercise 2 A key parameter for the Kermack-McKendrick model is the
epidemiological threshold, βS/γ.
Plot the time evolution of the model and investigate the influence
of the epidemiological threshold, in particular the cases:1. βS/γ < 1
2. βS/γ > 1
Starting values: S=I=500, R=0, β=0.0001
![Page 42: 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian](https://reader036.vdocuments.us/reader036/viewer/2022062322/5697bfa51a28abf838c977a6/html5/thumbnails/42.jpg)
2010-03-08 A. Johansson & W. Yu / [email protected] [email protected] 42
Exercise 3 - optional
Implement the Lotka-Volterra model and
investigate the influence of the timestep, dt.
How small must the timestep be in order for the
1st order Eulter‘s method to give reasonable
accuracy?
Check in the MATLAB help how the functions
ode23, ode45 etc, can be used for solving
differential equations.