Load the ilmtools package...


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


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

Generate a population from a bi-variate uniform distribution...


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


Out[2]:
ind_idxy
115.12501190473453316.15557099071509
2215.21910268755630111.972975436325328
3313.04603888147256510.08328633237483
4420.4975250979004825.16017648245416
553.155419196460279417.81252802351266
665.98996912417132950.8943337240064242
777.9825360376817262.3779127275929293
881.8564864643250815.942058418691229
999.77036178674560712.757690758824753
10100.93081435425483319.8055501259083
111118.9920053861537518.917773388123155
121216.0064321330614989.964991580137628
131322.727415079215463.0429663802547466
141424.19201897717725617.74396006200777
151515.15602213600470414.33869263473202
16168.39660463712407314.45706618253218
171711.942643366357122.772734215887762
18187.1406708869908522.565877600480826
19199.73834767926715720.864757336620716
20209.22354403611611723.563271743322467
21210.939977515312612220.366049788555486
222215.44908414731332510.46107982341753
232322.196864316810624.67909739676193
24246.93719358342256216.17759873761288
25255.7842811012746141.5513642177954812
262623.2350343372993326.624589564641497
272714.8079311340968244.256291772566207
282812.79512533189837224.961266891798985
292922.79247535687751711.08507152432776
303022.9207183513163413.440803802865753
&vellip&vellip&vellip&vellip

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


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


Out[3]:
edb(1000x4 DataFrame
| Row  | ind_id | s | i       | r       |
|------|--------|---|---------|---------|
| 1    | 1      | 0 | 1.28856 | 3.4151  |
| 2    | 2      | 0 | 1.62554 | 19.733  |
| 3    | 3      | 0 | 1.51886 | 11.458  |
| 4    | 4      | 0 | 1.86001 | 7.42561 |
| 5    | 5      | 0 | 1.26228 | 2.87442 |
| 6    | 6      | 0 | 1.89921 | 8.33897 |
| 7    | 7      | 0 | 1.8136  | 9.21274 |
| 8    | 8      | 0 | 1.3846  | 2.58653 |
| 9    | 9      | 0 | 1.33986 | 4.92792 |
| 10   | 10     | 0 | 1.36897 | 1.65071 |
| 11   | 11     | 0 | 1.61995 | 8.55315 |
⋮
| 989  | 989    | 0 | 1.62452 | 2.30524 |
| 990  | 990    | 0 | 1.58454 | 5.0418  |
| 991  | 991    | 0 | 1.6369  | 33.3878 |
| 992  | 992    | 0 | 1.82507 | 2.37633 |
| 993  | 993    | 0 | 1.95244 | 2.36642 |
| 994  | 994    | 0 | 1.7409  | 5.31333 |
| 995  | 995    | 0 | 1.34308 | 3.70939 |
| 996  | 996    | 0 | 1.74095 | 2.83141 |
| 997  | 997    | 0 | 1.27044 | 6.59653 |
| 998  | 998    | 0 | 1.62528 | 3.00566 |
| 999  | 999    | 0 | 1.69481 | 2.69461 |
| 1000 | 1000   | 0 | 1.87031 | 3.91214 |,[1.0,1.00044,1.00551,1.00563,1.0119,1.01246,1.03406,1.05569,1.05577,1.06241  …  26.6155,27.1867,27.1925,27.3699,27.7745,32.5808,33.3878,35.843,36.7957,38.9848],"continuous")

Visualize infection (susceptible, infected, and recovered) through time


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


Out[4]:
time -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 -40 -38 -36 -34 -32 -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 62 64 66 68 70 72 74 76 78 80 -50 0 50 100 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 -1500 -1000 -500 0 500 1000 1500 2000 2500 -1000 -950 -900 -850 -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 1650 1700 1750 1800 1850 1900 1950 2000 -1000 0 1000 2000 -1000 -900 -800 -700 -600 -500 -400 -300 -200 -100 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 S

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


Out[5]:
time -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 -40 -38 -36 -34 -32 -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 62 64 66 68 70 72 74 76 78 80 -50 0 50 100 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 -1500 -1000 -500 0 500 1000 1500 2000 2500 -1000 -950 -900 -850 -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 1650 1700 1750 1800 1850 1900 1950 2000 -1000 0 1000 2000 -1000 -900 -800 -700 -600 -500 -400 -300 -200 -100 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 I

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


Out[6]:
time -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 -40 -38 -36 -34 -32 -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 62 64 66 68 70 72 74 76 78 80 -50 0 50 100 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 -1500 -1000 -500 0 500 1000 1500 2000 2500 -1000 -950 -900 -850 -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 1650 1700 1750 1800 1850 1900 1950 2000 -1000 0 1000 2000 -1000 -900 -800 -700 -600 -500 -400 -300 -200 -100 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 R

Spatial plots with a time window of 0.1 (or watch a youtube demo https://www.youtube.com/watch?v=bD0Q2xLPpvo)


In [7]:
state_animation(0.1, evdb, pop_db1)


Out[7]:
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

In [8]: