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
1116.5424939065980221.7029552086238409
220.037077601027019074.0690903605710815
3322.49484706517368317.510959911646463
448.08255882651107215.551084589052405
5522.140637722667193.884843288709061
6612.236749945599489.61821950154892
7714.04295209683602512.650973913362185
8814.19643819179081115.044756362649508
9922.8875998968014084.743549511907935
101015.7695188992462046.967266527908489
11114.8266007239174688.049709415532119
12125.90116737499599723.280937343950598
13131.33315143449599944.710047548958235
141418.6743557759178622.45261702083365
15158.8037336433579313.21600577804522
161614.7322133084723216.91117114055188
171721.38450036836299312.747020367771999
18188.46427205019410423.932963079239116
19193.40180761658147612.709562741656827
202020.554586156368317.623816800726474
212116.98481675749360416.21656128595605
22220.447531635915926513.792814716921969
23230.54547152542756550.3762124782526466
242424.6367882478758959.216282490783517
25257.9896998908310590.7479441352435667
26265.248388200541592521.144716638358034
272714.65966578190787816.056752643954397
282811.4097555137740051.7164570301536286
29292.874884176249742617.015592192987995
30306.16284794692364522.312780046070813
&vellip&vellip&vellip&vellip

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


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


Out[3]:
edb(625x3 DataFrame
| Row | ind_id | s | i       |
|-----|--------|---|---------|
| 1   | 1      | 0 | 1.77486 |
| 2   | 2      | 0 | 6.76506 |
| 3   | 3      | 0 | 4.187   |
| 4   | 4      | 0 | 5.28364 |
| 5   | 5      | 0 | 2.07758 |
| 6   | 6      | 0 | 5.36726 |
| 7   | 7      | 0 | 4.70401 |
| 8   | 8      | 0 | 4.83334 |
| 9   | 9      | 0 | 2.64401 |
| 10  | 10     | 0 | 2.64552 |
| 11  | 11     | 0 | 6.21561 |
⋮
| 614 | 614    | 0 | 7.39744 |
| 615 | 615    | 0 | 6.82153 |
| 616 | 616    | 0 | 6.47597 |
| 617 | 617    | 0 | 5.39596 |
| 618 | 618    | 0 | 7.46262 |
| 619 | 619    | 0 | 6.47145 |
| 620 | 620    | 0 | 5.00431 |
| 621 | 621    | 0 | 5.63002 |
| 622 | 622    | 0 | 2.26329 |
| 623 | 623    | 0 | 2.25823 |
| 624 | 624    | 0 | 5.23677 |
| 625 | 625    | 0 | 6.34694 |,[1.0,1.00762,1.00869,1.00872,1.00872,1.06646,1.1694,1.44157,1.50368,1.50644  …  7.52112,7.72427,8.30596,8.30596,8.31047,9.00481,9.01952,9.17304,9.19385,13.5827],"continuous")

Visualize infection (susceptible and infected) through time


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


Out[4]:
time -20 -15 -10 -5 0 5 10 15 20 25 30 35 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5 29.0 29.5 30.0 -20 0 20 40 -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 -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 -20 -15 -10 -5 0 5 10 15 20 25 30 35 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5 29.0 29.5 30.0 -20 0 20 40 -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 -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 with a time window of 0.1 (youtube link: https://www.youtube.com/watch?v=QWcTAEdglGU)


In [6]:
state_animation(0.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