@@ -54,7 +54,7 @@ Every other Levy Process can be represented by these building blocks (e.g. a [Di
5454In this lecture, we will examine shocks driven by transformations of Brownian motion, as the prototypical Stochastic Differential Equation (SDE).
5555
5656``` {code-cell} julia
57- using LinearAlgebra, Statistics , Random, SparseArrays
57+ using LaTeXStrings, LinearAlgebra , Random, SparseArrays, Statistics
5858```
5959
6060``` {code-cell} julia
@@ -284,25 +284,25 @@ If we take two solutions and plot the number of infections, we will see differen
284284``` {code-cell} julia
285285sol_2 = solve(prob, SOSRI())
286286plot(sol_1, vars=[2], title = "Number of Infections", label = "Trajectory 1",
287- lm = 2, xlabel = "t", ylabel = "i(t)")
288- plot!(sol_2, vars=[2], label = "Trajectory 2", lm = 2, ylabel = "i(t)")
287+ lm = 2, xlabel = L "t", ylabel = L "i(t)")
288+ plot!(sol_2, vars=[2], label = "Trajectory 2", lm = 2, xlabel = L"t", ylabel = L "i(t)")
289289```
290290
291291The same holds for other variables such as the cumulative deaths, mortality, and $R_0$:
292292
293293``` {code-cell} julia
294294plot_1 = plot(sol_1, vars=[4], title = "Cumulative Death Proportion", label = "Trajectory 1",
295- lw = 2, xlabel = "t", ylabel = "d(t)", legend = :topleft)
296- plot!(plot_1, sol_2, vars=[4], label = "Trajectory 2", lw = 2)
295+ lw = 2, xlabel = L "t", ylabel = L "d(t)", legend = :topleft)
296+ plot!(plot_1, sol_2, vars=[4], label = "Trajectory 2", lw = 2, xlabel = L"t" )
297297plot_2 = plot(sol_1, vars=[3], title = "Cumulative Recovered Proportion", label = "Trajectory 1",
298- lw = 2, xlabel = "t", ylabel = "d(t)", legend = :topleft)
299- plot!(plot_2, sol_2, vars=[3], label = "Trajectory 2", lw = 2)
300- plot_3 = plot(sol_1, vars=[5], title = " R_0 transition from lockdown", label = "Trajectory 1",
301- lw = 2, xlabel = "t", ylabel = "R_0(t)")
302- plot!(plot_3, sol_2, vars=[5], label = "Trajectory 2", lw = 2)
298+ lw = 2, xlabel = L "t", ylabel = L "d(t)", legend = :topleft)
299+ plot!(plot_2, sol_2, vars=[3], label = "Trajectory 2", lw = 2, xlabel = L"t" )
300+ plot_3 = plot(sol_1, vars=[5], title = L"$ R_0$ transition from lockdown", label = "Trajectory 1",
301+ lw = 2, xlabel = L "t", ylabel = L "R_0(t)")
302+ plot!(plot_3, sol_2, vars=[5], label = "Trajectory 2", lw = 2, xlabel = L"t" )
303303plot_4 = plot(sol_1, vars=[6], title = "Mortality Rate", label = "Trajectory 1",
304- lw = 2, xlabel = "t", ylabel = " delta(t)", ylim = (0.006, 0.014))
305- plot!(plot_4, sol_2, vars=[6], label = "Trajectory 2", lw = 2)
304+ lw = 2, xlabel = L "t", ylabel = L"\ delta(t)", ylim = (0.006, 0.014))
305+ plot!(plot_4, sol_2, vars=[6], label = "Trajectory 2", lw = 2, xlabel = L"t" )
306306plot(plot_1, plot_2, plot_3, plot_4, size = (900, 600))
307307```
308308
@@ -324,7 +324,7 @@ For example:
324324``` {code-cell} julia
325325ensembleprob = EnsembleProblem(prob)
326326sol = solve(ensembleprob, SOSRI(), EnsembleSerial(), trajectories = 10)
327- plot(sol, vars = [2], title = "Infection Simulations", ylabel = "i(t)", xlabel = "t", lm = 2)
327+ plot(sol, vars = [2], title = "Infection Simulations", ylabel = L "i(t)", xlabel = L "t", lm = 2)
328328```
329329
330330Or, more frequently, you may want to run many trajectories and plot quantiles, which can be automatically run in [ parallel] ( https://docs.sciml.ai/stable/features/ensemble/ ) using multiple threads, processes, or GPUs. Here we showcase ` EnsembleSummary ` which calculates summary information from an ensemble and plots the mean of the solution along with calculated quantiles of the simulation:
@@ -333,8 +333,8 @@ Or, more frequently, you may want to run many trajectories and plot quantiles, w
333333trajectories = 100 # choose larger for smoother quantiles
334334sol = solve(ensembleprob, SOSRI(), EnsembleThreads(), trajectories = trajectories)
335335summ = EnsembleSummary(sol) # defaults to saving 0.05, 0.95 quantiles
336- plot(summ, idxs = (2,), title = "Quantiles of Infections Ensemble", ylabel = "i(t)",
337- xlabel = "t", labels = "Middle 95% Quantile", legend = :topright)
336+ plot(summ, idxs = (2,), title = "Quantiles of Infections Ensemble", ylabel = L "i(t)",
337+ xlabel = L "t", labels = "Middle 95% Quantile", legend = :topright)
338338```
339339
340340In addition, you can calculate more quantiles and stack graphs
@@ -345,8 +345,8 @@ summ = EnsembleSummary(sol) # defaults to saving 0.05, 0.95 quantiles
345345summ2 = EnsembleSummary(sol, quantiles = (0.25, 0.75))
346346
347347plot(summ, idxs = (2,4,5,6),
348- title = ["Proportion Infected" "Proportion Dead" "R_0" " delta"],
349- ylabel = ["i(t)" "d(t)" "R_0(t)" " delta(t)"], xlabel = "t",
348+ title = ["Proportion Infected" "Proportion Dead" L "R_0" L"\ delta"],
349+ ylabel = [L "i(t)" L "d(t)" L "R_0(t)" L"\ delta(t)"], xlabel = L "t",
350350 legend = [:topleft :topleft :bottomright :bottomright],
351351 labels = "Middle 95% Quantile", layout = (2, 2), size = (900, 600))
352352plot!(summ2, idxs = (2,4,5,6),
@@ -385,14 +385,14 @@ end
385385summ_1 = generate_η_experiment(η_1)
386386summ_2 = generate_η_experiment(η_2)
387387plot(summ_1, idxs = (4,5),
388- title = ["Proportion Dead" "R_0"],
389- ylabel = ["d(t)" "R_0(t)"], xlabel = "t",
388+ title = ["Proportion Dead" L "R_0"],
389+ ylabel = [L "d(t)" L "R_0(t)"], xlabel = L "t",
390390 legend = [:topleft :bottomright],
391- labels = "Middle 95% Quantile, eta = $η_1",
391+ labels = L "Middle 95% Quantile, $\ eta = % $η_1$ ",
392392 layout = (2, 1), size = (900, 900), fillalpha = 0.5)
393393plot!(summ_2, idxs = (4,5),
394394 legend = [:topleft :bottomright],
395- labels = "Middle 95% Quantile, eta = $η_2", size = (900, 900), fillalpha = 0.5)
395+ labels = L "Middle 95% Quantile, $\ eta = % $η_2$ ", size = (900, 900), fillalpha = 0.5)
396396```
397397
398398While the the mean of the $d(t)$ increases, unsurprisingly, we see that the 95% quantile for later time periods is also much larger - even after the $R_0$ has converged.
@@ -439,14 +439,14 @@ Simulating for a single realization of the shocks, we see the results are qualit
439439sol_early = solve(prob_early, SOSRI())
440440sol_late = solve(prob_late, SOSRI())
441441plot(sol_early, vars = [5, 1,2,4],
442- title = ["R_0" "Susceptible" "Infected" "Dead"],
442+ title = [L "R_0" "Susceptible" "Infected" "Dead"],
443443 layout = (2, 2), size = (900, 600),
444- ylabel = ["R_0(t)" "s(t)" "i(t)" "d(t)"], xlabel = "t",
444+ ylabel = [L "R_0(t)" L "s(t)" L "i(t)" L "d(t)"], xlabel = L "t",
445445 legend = [:bottomright :topright :topright :topleft],
446446 label = ["Early" "Early" "Early" "Early"])
447447plot!(sol_late, vars = [5, 1,2,4],
448448 legend = [:bottomright :topright :topright :topleft],
449- label = ["Late" "Late" "Late" "Late"])
449+ label = ["Late" "Late" "Late" "Late"], xlabel = L"t" )
450450```
451451
452452However, note that this masks highly volatile values induced by the in $R_0$ variation, as seen in the ensemble
@@ -462,8 +462,8 @@ summ_early = EnsembleSummary(ensemble_sol_early)
462462summ_late = EnsembleSummary(ensemble_sol_late)
463463
464464plot(summ_early, idxs = (5, 1, 2, 4),
465- title = ["R_0" "Susceptible" "Infected" "Dead"], layout = (2, 2), size = (900, 600),
466- ylabel = ["R_0(t)" "s(t)" "i(t)" "d(t)"], xlabel = "t",
465+ title = [L "R_0" "Susceptible" "Infected" "Dead"], layout = (2, 2), size = (900, 600),
466+ ylabel = [L "R_0(t)" L "s(t)" L "i(t)" L "d(t)"], xlabel = L "t",
467467 legend = [:bottomright :topright :topright :topleft],
468468 label = ["Early" "Early" "Early" "Early"])
469469plot!(summ_late, idxs = (5, 1,2,4),
@@ -485,12 +485,12 @@ bins_2 = 30 # number rather than grid.
485485hist_1 = histogram([ensemble_sol_early.u[i](t_1)[4] for i in 1:trajectories],
486486 fillalpha = 0.5, normalize = :probability,
487487 legend = :topleft, bins = bins_1,
488- label = "Early", title = "Death Proportion at t = $t_1")
488+ label = "Early", title = L "Death Proportion at $ t = % $t_1$ ")
489489histogram!(hist_1, [ensemble_sol_late.u[i](t_1)[4] for i in 1:trajectories],
490490 label = "Late", fillalpha = 0.5, normalize = :probability, bins = bins_1)
491491hist_2 = histogram([ensemble_sol_early.u[i][4, end] for i in 1:trajectories],
492492 fillalpha = 0.5, normalize = :probability, bins = bins_2,
493- label = "Early", title = "Death Proportion at t = $t_2")
493+ label = "Early", title = L "Death Proportion at $ t = % $t_2$ ")
494494histogram!(hist_2, [ensemble_sol_late.u[i][4, end] for i in 1:trajectories],
495495 label = "Late", fillalpha = 0.5, normalize = :probability, bins = bins_2)
496496plot(hist_1, hist_2, size = (600,600), layout = (2, 1))
@@ -572,12 +572,12 @@ The ensemble simulations for the $\nu = 0$ and $\nu > 0$ can be compared to see
572572plot(summ_late, idxs = (1, 2, 3, 4),
573573 title = ["Susceptible" "Infected" "Recovered" "Dead"],
574574 layout = (2, 2), size = (900, 600),
575- ylabel = ["s(t)" "i(t)" "r(t)" "d(t)"], xlabel = "t",
575+ ylabel = [L "s(t)" L "i(t)" L "r(t)" L "d(t)"], xlabel = L "t",
576576 legend = :topleft,
577- label = ["s(t)" "i(t)" "r(t)" "d(t)"])
577+ label = [L "s(t)" L "i(t)" L "r(t)" L "d(t)"])
578578plot!(summ_re_late, idxs = (1, 2, 3, 4),
579579 legend = :topleft,
580- label = ["s(t); nu > 0" "i(t); nu > 0" "r(t); nu > 0" "d(t); nu > 0"])
580+ label = [L "s(t); \ nu > 0" L "i(t); \ nu > 0" L "r(t); \ nu > 0" L "d(t); \ nu > 0"])
581581```
582582
583583Finally, we can examine the same early vs. late lockdown histogram
@@ -588,12 +588,12 @@ bins_re_2 = range(0.0085, 0.0102, length = 50)
588588hist_re_1 = histogram([ensemble_sol_re_early.u[i](t_1)[4] for i in 1:trajectories],
589589 fillalpha = 0.5, normalize = :probability,
590590 legend = :topleft, bins = bins_re_1,
591- label = "Early", title = "Death Proportion at t = $t_1")
591+ label = "Early", title = L "Death Proportion at $ t = % $t_1$ ")
592592histogram!(hist_re_1, [ensemble_sol_re_late.u[i](t_1)[4] for i in 1:trajectories],
593593 label = "Late", fillalpha = 0.5, normalize = :probability, bins = bins_re_1)
594594hist_re_2 = histogram([ensemble_sol_re_early.u[i][4, end] for i in 1:trajectories],
595595 fillalpha = 0.5, normalize = :probability, bins = bins_re_2,
596- label = "Early", title = "Death Proportion at t = $t_2")
596+ label = "Early", title = L "Death Proportion at $ t = % $t_2$ ")
597597histogram!(hist_re_2, [ensemble_sol_re_late.u[i][4, end] for i in 1:trajectories],
598598 label = "Late", fillalpha = 0.5, normalize = :probability,
599599 bins = bins = bins_re_2)
0 commit comments