Load the ilmtools package...


In [1]:
include("ilmtools.jl")


Out[1]:
state_animation (generic function with 1 method)

Generate a population with a bivariate uniform spatial distribution (over a 25 by 25 unit area)


In [2]:
pop_db1 = create_pop_db_univariates(625, Uniform(0,25), Uniform(0,25))


Out[2]:
ind_idxy
118.6507267091927021.4218414086561326
2224.2720966715184050.5971098060924607
3315.8828682872750641.7770569055388874
4423.9148560170617669.511705711875507
5516.28550956644732814.553265005492166
6623.30687627244635312.712318552270652
7716.449742586770797.756321970097452
886.7074697673040977.569802421312638
9919.5710207145372342.221499681837064
101016.3518047713208116.310651932557512
111119.10557079612403421.818485512536988
121223.441588506276920.7821575045064033
13133.8475401468340940.7511514033209821
141422.7612332836120327.441012629393878
151512.83894554339308815.112294213287726
16161.824208538713484320.37368008717571
171724.37119045641682619.317396202443
181813.14743112319117724.78103074492241
19198.56553633277630815.210855364197911
202012.5803490146075457.665241181726307
21210.799468686218307619.446564136715814
222218.8140977719397219.759420280073897
23230.0945430327415230910.26606314086081
242419.6767143021915849.951717062732806
252512.56449840984882913.186816753860937
262617.36867944168858823.558642035451623
272711.3173626582041456.30114483201718
282821.62698569383172421.20704174198984
292917.8913330172529415.414659410338793
30304.707425522377594.911529802226933
&vellip&vellip&vellip&vellip

Generate the initial infection and propagate infection through population (SI model) in discrete time with parameters $\alpha=2$ and $\beta=6$.


In [3]:
evdb = infect_recover_loop(pop_db1, "discrete", "SI", 2, 6, Inf)


Out[3]:
edb(625x3 DataFrame
| Row | ind_id | s | i    |
|-----|--------|---|------|
| 1   | 1      | 0 | 17.0 |
| 2   | 2      | 0 | 19.0 |
| 3   | 3      | 0 | 15.0 |
| 4   | 4      | 0 | 13.0 |
| 5   | 5      | 0 | 6.0  |
| 6   | 6      | 0 | 14.0 |
| 7   | 7      | 0 | 11.0 |
| 8   | 8      | 0 | 17.0 |
| 9   | 9      | 0 | 22.0 |
| 10  | 10     | 0 | 5.0  |
| 11  | 11     | 0 | 6.0  |
⋮
| 614 | 614    | 0 | 7.0  |
| 615 | 615    | 0 | 11.0 |
| 616 | 616    | 0 | 9.0  |
| 617 | 617    | 0 | 14.0 |
| 618 | 618    | 0 | 7.0  |
| 619 | 619    | 0 | 16.0 |
| 620 | 620    | 0 | 14.0 |
| 621 | 621    | 0 | 9.0  |
| 622 | 622    | 0 | 16.0 |
| 623 | 623    | 0 | 6.0  |
| 624 | 624    | 0 | 16.0 |
| 625 | 625    | 0 | 10.0 |,[1.0,2.0,2.0,2.0,2.0,2.0,2.0,3.0,3.0,3.0  …  24.0,25.0,25.0,25.0,25.0,25.0,26.0,26.0,27.0,28.0],"discrete")

Visualize infection (susceptible and infected) through time


In [4]:
evseries = state_timeseries(evdb)
plot(evseries, x="time", y="S", Geom.line)


Out[4]:
time -40 -30 -20 -10 0 10 20 30 40 50 60 70 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 -30 0 30 60 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 -1000 -800 -600 -400 -200 0 200 400 600 800 1000 1200 1400 1600 1800 -800 -750 -700 -650 -600 -550 -500 -450 -400 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 -1000 0 1000 2000 -800 -750 -700 -650 -600 -550 -500 -450 -400 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 S

In [5]:
plot(evseries, x="time", y="I", Geom.line)


Out[5]:
time -40 -30 -20 -10 0 10 20 30 40 50 60 70 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 -30 0 30 60 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 -1000 -800 -600 -400 -200 0 200 400 600 800 1000 1200 1400 1600 1800 -800 -750 -700 -650 -600 -550 -500 -450 -400 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 -1000 0 1000 2000 -800 -750 -700 -650 -600 -550 -500 -450 -400 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 I

Spatial plots...


In [6]:
state_animation(1, evdb, pop_db1)


Out[6]:
x -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 -25 0 25 50 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 S I R state -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 -25 0 25 50 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 y