bondscell_results$f1f89502-0494-11eb-2303-0b79d8bbd13fqueued¤logsrunning¦outputbody;frequencies_plot_with_mean (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAnd˰persist_js_state·has_pluto_hook_features§cell_id$f1f89502-0494-11eb-2303-0b79d8bbd13fdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$95771ce2-0403-11eb-3056-f1dc3a8b7ec3queued¤logsrunning¦outputbodyh

👉 Write a function simulation that does the following:

  1. Generate the $N$ agents.

  2. Run sweep! a number $T$ of times. Calculate and store the total number of agents with each status at each step in variables S_counts, I_counts and R_counts.

  3. Return the vectors S_counts, I_counts and R_counts in a named tuple, with keys S, I and R.

You've seen an example of named tuples before: the student variable at the top of the notebook!

Feel free to store the counts in a different way, as long as the return type is the same.

mimetext/htmlrootassigneelast_run_timestampAtnpersist_js_state·has_pluto_hook_features§cell_id$95771ce2-0403-11eb-3056-f1dc3a8b7ec3depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$e6219c7c-0420-11eb-3faa-13126f7c8007queued¤logsrunning¦outputbody٤

Abstraction, lines 1-219

Array Basics, lines 1-137

Course Intro, lines 1-44

(for example)

mimetext/htmlrootassigneelines_i_editedlast_run_timestampAXpersist_js_state·has_pluto_hook_features§cell_id$e6219c7c-0420-11eb-3faa-13126f7c8007depends_on_disabled_cells§runtime=published_object_keysdepends_on_skipped_cells§errored$b817f466-04d4-11eb-0a26-c1c667f9f7f7queued¤logsrunning¦outputbody٥

Here we go!

Replace missing with your answer.

mimetext/htmlrootassigneelast_run_timestampASpersist_js_state·has_pluto_hook_features§cell_id$b817f466-04d4-11eb-0a26-c1c667f9f7f7depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$08e2bc64-0417-11eb-1457-21c0d18e8c51queued¤logsrunning¦outputbody

Hint

Do you remember how we worked with dictionaries in Homework 3? You can create an empty dictionary using Dict(). You may want to use either the function haskey or the function get on your dictionary – check the documentation for how to use these functions.

mimetext/htmlrootassigneelast_run_timestampA [հpersist_js_state·has_pluto_hook_features§cell_id$08e2bc64-0417-11eb-1457-21c0d18e8c51depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$bb8aeb58-042f-11eb-18b8-f995631df619queued¤logsrunning¦outputbody

As you separately vary $p$ and $N$, what do you observe about the mean in each case? Does that make sense?

mimetext/htmlrootassigneelast_run_timestampAqpersist_js_state·has_pluto_hook_features§cell_id$bb8aeb58-042f-11eb-18b8-f995631df619depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$223933a4-042c-11eb-10d3-852229f25a35queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAʫްpersist_js_state·has_pluto_hook_features§cell_id$223933a4-042c-11eb-10d3-852229f25a35depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampA{rupersist_js_state·has_pluto_hook_features§cell_id$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$7f635722-04d0-11eb-3209-4b603c9e843cqueued¤logsrunning¦outputbodymsgQMethodError: no method matching length(::Missing) Closest candidates are:  length(::Union{Base.KeySet, Base.ValueIterator}) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/abstractdict.jl:58  length(::Union{LinearAlgebra.Adjoint{T, S}, LinearAlgebra.Transpose{T, S}} where {T, S}) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/stdlib/v1.7/LinearAlgebra/src/adjtrans.jl:171  length(::Union{DataStructures.OrderedRobinDict, DataStructures.RobinDict}) at ~/.julia/packages/DataStructures/IrAJn/src/ordered_robin_dict.jl:86  ...stacktracecall_short^sir_mean_plot(simulations::Vector{NamedTuple{(:S, :I, :R), Tuple{Missing, Missing, Missing}}})inlined£urlًhttps://github.com/fonsp/disorganised-mess/tree/6d5f6e46c196925a19e151358b6656510197d2e1//hw4.jl#==#843fd63c-04d0-11eb-0113-c58d346179d6#L1pathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#843fd63c-04d0-11eb-0113-c58d346179d6source_packagecall^sir_mean_plot(simulations::Vector{NamedTuple{(:S, :I, :R), Tuple{Missing, Missing, Missing}}})linfo_typeCore.MethodInstancelinefile.hw4.jl#==#843fd63c-04d0-11eb-0113-c58d346179d6funcsir_mean_plotparent_modulefrom_cŒcall_shorttop-level scopeinlinedãurlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#7f635722-04d0-11eb-3209-4b603c9e843csource_packagecalltop-level scopelinfo_typeNothinglinefile.hw4.jl#==#7f635722-04d0-11eb-3209-4b603c9e843cfunc##function_wrapped_cell#413parent_modulefrom_c¤mime'application/vnd.pluto.stacktrace+objectrootassigneelast_run_timestampA߰persist_js_state·has_pluto_hook_features§cell_id$7f635722-04d0-11eb-3209-4b603c9e843cdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$7c515a7a-04d5-11eb-0f36-4fcebff709d5queued¤logsrunning¦outputbodyٜ

Keep working on it!

The answer is not quite right.

mimetext/htmlrootassigneelast_run_timestampAVcZpersist_js_state·has_pluto_hook_features§cell_id$7c515a7a-04d5-11eb-0f36-4fcebff709d5depends_on_disabled_cells§runtime۵published_object_keysdepends_on_skipped_cells§errored$107e65a4-0403-11eb-0c14-37d8d828b469queued¤logsrunning¦outputbodyT

Let's create a package environment:

mimetext/htmlrootassigneelast_run_timestampApIspersist_js_state·has_pluto_hook_features§cell_id$107e65a4-0403-11eb-0c14-37d8d828b469depends_on_disabled_cells§runtimePbpublished_object_keysdepends_on_skipped_cells§errored$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAv#persist_js_state·has_pluto_hook_features§cell_id$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0depends_on_disabled_cells§runtimenpublished_object_keysdepends_on_skipped_cells§errored$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bbqueued¤logsrunning¦outputbody

In the cell below, we plot the evolution of the number of $I$ individuals as a function of time for each of the simulations on the same plot using transparency (alpha=0.5 inside the plot command).

mimetext/htmlrootassigneelast_run_timestampAupersist_js_state·has_pluto_hook_features§cell_id$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bbdepends_on_disabled_cells§runtime`published_object_keysdepends_on_skipped_cells§errored$7f4e121c-041d-11eb-0dff-cd0cbfdfd606queued¤logsrunning¦outputbodymissingmimetext/plainrootassigneetest_statuslast_run_timestampAr^persist_js_state·has_pluto_hook_features§cell_id$7f4e121c-041d-11eb-0dff-cd0cbfdfd606depends_on_disabled_cells§runtime(published_object_keysdepends_on_skipped_cells§errored$4f19e872-0414-11eb-0dfd-e53d2aecc4dcqueued¤logsrunning¦outputbodyn

Function library

Just some helper functions used in the notebook.

mimetext/htmlrootassigneelast_run_timestampAwypersist_js_state·has_pluto_hook_features§cell_id$4f19e872-0414-11eb-0dfd-e53d2aecc4dcdepends_on_disabled_cells§runtimeapublished_object_keysdepends_on_skipped_cells§errored$5689841e-0414-11eb-0492-63c77ddbd136queued¤logsrunning¦outputbody




mimetext/htmlrootassigneelast_run_timestampAxpersist_js_state·has_pluto_hook_features§cell_id$5689841e-0414-11eb-0492-63c77ddbd136depends_on_disabled_cells§runtime$published_object_keysdepends_on_skipped_cells§errored$759bc42e-04ab-11eb-0ab1-b12e008c02a9queued¤logsrunning¦outputbody

Keep working on it!

The agent should recover from an infectious state with the right probability.

mimetext/htmlrootassigneelast_run_timestampA`䛰persist_js_state·has_pluto_hook_features§cell_id$759bc42e-04ab-11eb-0ab1-b12e008c02a9depends_on_disabled_cells§runtime

👉 Make a new method for the interact! function that accepts the new infection type as argument, reusing as much functionality as possible from the previous version.

Write it in the same cell as our previous interact! method, and use a begin block to group the two definitions together.

mimetext/htmlrootassigneelast_run_timestampAv뎰persist_js_state·has_pluto_hook_features§cell_id$99ef7b2a-0403-11eb-08ef-e1023cd151aedepends_on_disabled_cells§runtimeMpublished_object_keysdepends_on_skipped_cells§errored$77b54c10-0403-11eb-16ad-65374d29a817queued¤logsrunning¦outputbody

👉 Write an interactive visualization that draws the histogram and mean for $p$ between $0.01$ (not $0$!) and $1$, and $N$ between $1$ and $100,000$, say. To avoid a naming conflict, call them p_interactive and N_interactive, instead of just p and N.

mimetext/htmlrootassigneelast_run_timestampAq?persist_js_state·has_pluto_hook_features§cell_id$77b54c10-0403-11eb-16ad-65374d29a817depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$7768a2dc-0403-11eb-39b7-fd660dc952fequeued¤logsrunning¦outputbodyٲ

👉 Write the function frequencies_plot_with_mean that calculates the mean recovery time and displays it using a vertical line.

mimetext/htmlrootassigneelast_run_timestampAqְpersist_js_state·has_pluto_hook_features§cell_id$7768a2dc-0403-11eb-39b7-fd660dc952fedepends_on_disabled_cells§runtimeQpublished_object_keysdepends_on_skipped_cells§errored$60a8b708-04c8-11eb-37b1-3daec644ac90queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAsIpersist_js_state·has_pluto_hook_features§cell_id$60a8b708-04c8-11eb-37b1-3daec644ac90depends_on_disabled_cells§runtime!published_object_keysdepends_on_skipped_cells§errored$95eb9f88-0403-11eb-155b-7b2d3a07cff0queued¤logsrunning¦outputbodyO

👉 Write a function sir_mean_error_plot that does the same as sir_mean_plot, which also computes the standard deviation $\sigma$ of $S$, $I$, $R$ at each step. Add this to the plot using error bars, using the option yerr=σ in the plot command; use transparency.

This should confirm that the distribution of $I$ at each step is pretty wide!

mimetext/htmlrootassigneelast_run_timestampAv?Opersist_js_state·has_pluto_hook_features§cell_id$95eb9f88-0403-11eb-155b-7b2d3a07cff0depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$955321de-0403-11eb-04ce-fb1670dfbb9equeued¤logsrunning¦outputbodyC

👉 Write a function sweep!. It runs step! $N$ times, where $N$ is the number of agents. Thus each agent acts, on average, once per sweep; a sweep is thus the unit of time in our Monte Carlo simulation.

mimetext/htmlrootassigneelast_run_timestampAtIMpersist_js_state·has_pluto_hook_features§cell_id$955321de-0403-11eb-04ce-fb1670dfbb9edepends_on_disabled_cells§runtimeyfpublished_object_keysdepends_on_skipped_cells§errored$ae70625a-041f-11eb-3082-0753419d6d57queued¤logsrunning¦outputbody

When you define a new type like this, Julia automatically defines one or more constructors, which are methods of a generic function with the same name as the type. These are used to create objects of that type.

👉 Use the methods function to check how many constructors are pre-defined for the Agent type.

mimetext/htmlrootassigneelast_run_timestampArvpersist_js_state·has_pluto_hook_features§cell_id$ae70625a-041f-11eb-3082-0753419d6d57depends_on_disabled_cells§runtimeapublished_object_keysdepends_on_skipped_cells§errored$843fd63c-04d0-11eb-0113-c58d346179d6queued¤logsrunning¦outputbody.sir_mean_plot (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampApersist_js_state·has_pluto_hook_features§cell_id$843fd63c-04d0-11eb-0113-c58d346179d6depends_on_disabled_cells§runtime h%published_object_keysdepends_on_skipped_cells§errored$189cae1e-0424-11eb-2666-65bf297d8bddqueued¤logsrunning¦outputbodyٕ

👉 Create an agent test_agent with status S and num_infected equal to 0.

mimetext/htmlrootassigneelast_run_timestampAs&cpersist_js_state·has_pluto_hook_features§cell_id$189cae1e-0424-11eb-2666-65bf297d8bdddepends_on_disabled_cells§runtimeupublished_object_keysdepends_on_skipped_cells§errored$7f744644-041d-11eb-08a0-3719cc0adeb7queued¤logsrunning¦outputbody{

👉 Use the typeof function to find the type of test_status.

mimetext/htmlrootassigneelast_run_timestampArpersist_js_state·has_pluto_hook_features§cell_id$7f744644-041d-11eb-08a0-3719cc0adeb7depends_on_disabled_cells§runtime5published_object_keysdepends_on_skipped_cells§errored$488771e2-049f-11eb-3b0a-0de260457731queued¤logsrunning¦outputbodymissingmimetext/plainrootassigneelast_run_timestampAʫpersist_js_state·has_pluto_hook_features§cell_id$488771e2-049f-11eb-3b0a-0de260457731depends_on_disabled_cells§runtime)published_object_keysdepends_on_skipped_cells§errored$393041ec-049f-11eb-3089-2faf378445f3queued¤logsrunning¦outputbody٥

Here we go!

Replace missing with your answer.

mimetext/htmlrootassigneelast_run_timestampAYpersist_js_state·has_pluto_hook_features§cell_id$393041ec-049f-11eb-3089-2faf378445f3depends_on_disabled_cells§runtimedpublished_object_keysdepends_on_skipped_cells§errored$531d13c2-0414-11eb-0acd-4905a684869dqueued¤logsrunning¦outputbody

Before you submit

Remember to fill in your name and Kerberos ID at the top of this notebook.

mimetext/htmlrootassigneelast_run_timestampA persist_js_state·has_pluto_hook_features§cell_id$531d13c2-0414-11eb-0acd-4905a684869ddepends_on_disabled_cells§runtimeTYpublished_object_keysdepends_on_skipped_cells§errored$06f30b2a-0403-11eb-0f05-8badebe1011dqueued¤logsrunning¦outputbodyu

Homework 4: Epidemic modeling I

18.S191, fall 2020

This notebook contains built-in, live answer checks! In some exercises you will see a coloured box, which runs a test case on your code, and provides feedback based on the result. Simply edit the code, run it, and the check runs again.

For MIT students: there will also be some additional (secret) test cases that will be run as part of the grading process, and we will look at your notebook and write comments.

Feel free to ask questions!

mimetext/htmlrootassigneelast_run_timestampAp0װpersist_js_state·has_pluto_hook_features§cell_id$06f30b2a-0403-11eb-0f05-8badebe1011ddepends_on_disabled_cells§runtimefpublished_object_keysdepends_on_skipped_cells§errored$9c39974c-04a5-11eb-184d-317eb542452cqueued¤logsrunning¦outputbodyelementsagentprefixAgentelementsstatusS::InfectionStatus = 0text/plainnum_infected0text/plaintypestructprefix_shortAgentobjectid8f17d8b939254d92!application/vnd.pluto.tree+objectsourceprefixAgentelementsstatusI::InfectionStatus = 1text/plainnum_infected0text/plaintypestructprefix_shortAgentobjectid709f2124fc33ddc2!application/vnd.pluto.tree+objecttypeNamedTupleobjectid7ce78337241724aemime!application/vnd.pluto.tree+objectrootassigneelast_run_timestampAϠװpersist_js_state·has_pluto_hook_features§cell_id$9c39974c-04a5-11eb-184d-317eb542452cdepends_on_disabled_cells§runtime͟ published_object_keysdepends_on_skipped_cells§errored$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1queued¤logsrunning¦outputbodymsgMethodError: no method matching frequencies_plot_with_maximum(::Missing) Closest candidates are:  frequencies_plot_with_maximum(::Vector) at ~/work/disorganised-mess/disorganised-mess/hw4.jl#==#823364ce-041c-11eb-2467-7ffa4f751527:1stacktracecall_shorttop-level scopeinlinedãurlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#1ddbaa18-0494-11eb-1fc8-250ab6ae89f1source_packagecalltop-level scopelinfo_typeNothinglinefile.hw4.jl#==#1ddbaa18-0494-11eb-1fc8-250ab6ae89f1func##function_wrapped_cell#332parent_modulefrom_c¤mime'application/vnd.pluto.stacktrace+objectrootassigneelast_run_timestampAcpersist_js_state·has_pluto_hook_features§cell_id$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$06089d1e-0495-11eb-0ace-a7a7dc60e5b2queued¤logsrunning¦outputbodymissingmimetext/plainrootassigneelast_run_timestampAnpersist_js_state·has_pluto_hook_features§cell_id$06089d1e-0495-11eb-0ace-a7a7dc60e5b2depends_on_disabled_cells§runtime/published_object_keysdepends_on_skipped_cells§errored$15187690-0403-11eb-2dfd-fd924faa3513queued¤logslinemsg;Failed to load integration with PlotlyBase & PlotlyKaleido.text/plaincell_id$15187690-0403-11eb-2dfd-fd924faa3513kwargsexceptionmsgيArgumentError: Package PlotlyBase not found in current path: - Run `import Pkg; Pkg.add("PlotlyBase")` to install the PlotlyBase package. stacktracecall_short"require(into::Module, mod::Symbol)inlined£urlehttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/loading.jl#L959path./loading.jlsource_packagecall"require(into::Module, mod::Symbol)linfo_typeCore.MethodInstancelineǤfileloading.jlfuncrequireparent_modulefrom_cŒcall_shorttop-level scopeinlined£urlpath8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jlsource_packagecalltop-level scopelinfo_typeCore.CodeInfoline8filebackends.jlfunctop-level scopeparent_modulefrom_cŒcall_shortevalinlinedãurlpath./boot.jlsource_packagecallevallinfo_typeNothinglineufileboot.jlfuncevalparent_modulefrom_cŒcall_short-_initialize_backend(pkg::Plots.PlotlyBackend)inlined£url?file:///home/runner/.julia/packages/Plots/uiCPf/src/backends.jlpath8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jlsource_packagecall-_initialize_backend(pkg::Plots.PlotlyBackend)linfo_typeCore.MethodInstanceline7filebackends.jlfunc_initialize_backendparent_modulefrom_cŒcall_short!backend(pkg::Plots.PlotlyBackend)inlined£url?file:///home/runner/.julia/packages/Plots/uiCPf/src/backends.jlpath8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jlsource_packagecall!backend(pkg::Plots.PlotlyBackend)linfo_typeCore.MethodInstancelinefilebackends.jlfuncbackendparent_modulefrom_cŒcall_short#plotly#324inlinedãurlpath8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jlsource_packagecall#plotly#324linfo_typeNothinglineVfilebackends.jlfunc#plotly#324parent_modulefrom_cŒcall_shortplotly()inlined£url?file:///home/runner/.julia/packages/Plots/uiCPf/src/backends.jlpath8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jlsource_packagecallplotly()linfo_typeCore.MethodInstancelineVfilebackends.jlfuncplotlyparent_modulefrom_cŒcall_shorttop-level scopeinlined£urlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#15187690-0403-11eb-2dfd-fd924faa3513source_packagecalltop-level scopelinfo_typeCore.CodeInfolinefile.hw4.jl#==#15187690-0403-11eb-2dfd-fd924faa3513functop-level scopeparent_modulefrom_c'application/vnd.pluto.stacktrace+objectidPlots_b627f5e6file8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jlgroupbackendslevelWarnlinemsg)1 Updating registry at `~/.julia/registries/General.toml`  Resolving package versions...  Updating `/tmp/jl_tSReBH/Project.toml`  [91a5bcdd] + Plots v1.40.14  [7f904dfe] + PlutoUI v0.7.64  Updating `/tmp/jl_tSReBH/Manifest.toml`  [6e696c72] + AbstractPlutoDingetjes v1.3.2  [66dad0bd] + AliasTables v1.1.3  [d1d4a3ce] + BitFlags v0.1.9  [d360d2e6] + ChainRulesCore v1.25.1  [9e997f8a] + ChangesOfVariables v0.1.10  [944b1d66] + CodecZlib v0.7.8  [35d6a980] + ColorSchemes v3.29.0  [3da002f7] + ColorTypes v0.12.1  [c3611d14] + ColorVectorSpace v0.11.0  [5ae59095] + Colors v0.13.1  [34da2185] + Compat v4.16.0  [f0e56b4a] + ConcurrentUtilities v2.5.0  [187b0558] + ConstructionBase v1.5.8  [d38c429a] + Contour v0.6.3  [9a962f9c] + DataAPI v1.16.0  [864edb3b] + DataStructures v0.18.22  [ffbed154] + DocStringExtensions v0.9.5  [460bff9d] + ExceptionUnwrapping v0.1.11  [c87230d0] + FFMPEG v0.4.2  [53c48c17] + FixedPointNumbers v0.8.5  [1fa38f19] + Format v1.3.7  [28b8d3ca] + GR v0.73.6  [42e2da0e] + Grisu v1.0.2  [cd3eb016] + HTTP v1.10.16  [47d2ed2b] + Hyperscript v0.0.5  [ac1192a8] + HypertextLiteral v0.9.5  [b5f81e59] + IOCapture v0.2.5  [3587e190] + InverseFunctions v0.1.17  [92d709cd] + IrrationalConstants v0.2.4  [1019f520] + JLFzf v0.1.11  [692b3bcd] + JLLWrappers v1.7.0  [682c06a0] + JSON v0.21.4  [b964fa9f] + LaTeXStrings v1.4.0  [23fbe1c1] + Latexify v0.16.8  [2ab3a3ac] + LogExpFunctions v0.3.28  [e6f89c97] + LoggingExtras v1.1.0  [6c6e2e6c] + MIMEs v1.1.0  [1914dd2f] + MacroTools v0.5.16  [739be429] + MbedTLS v1.1.9  [442fdcdd] + Measures v0.3.2  [e1d29d7a] + Missings v1.2.0  [77ba4419] + NaNMath v1.0.3  [4d8831e6] + OpenSSL v1.5.0  [bac558e1] + OrderedCollections v1.8.1  [69de0a69] + Parsers v2.8.3  [ccf2f8ad] + PlotThemes v3.3.0  [995b91a9] + PlotUtils v1.4.3  [91a5bcdd] + Plots v1.40.14  [7f904dfe] + PlutoUI v0.7.64  [aea7be01] + PrecompileTools v1.2.1  [21216c6a] + Preferences v1.4.3  [43287f4e] + PtrArrays v1.3.0  [3cdcf5f2] + RecipesBase v1.3.4  [01d81517] + RecipesPipeline v0.6.12  [189a3867] + Reexport v1.2.2  [05181044] + RelocatableFolders v1.0.1  [ae029012] + Requires v1.3.1  [6c6a2e73] + Scratch v1.2.1  [992d4aef] + Showoff v1.0.3  [777ac1f9] + SimpleBufferStream v1.2.0  [a2af1166] + SortingAlgorithms v1.2.1  [860ef19b] + StableRNGs v1.0.3  [82ae8749] + StatsAPI v1.7.1  [2913bbd2] + StatsBase v0.34.4  [62fd8b95] + TensorCore v0.1.1  [3bb67fe8] + TranscodingStreams v0.11.3  [410a4b4d] + Tricks v0.1.10  [5c2747f8] + URIs v1.5.2  [1cfade01] + UnicodeFun v0.4.1  [1986cc42] + Unitful v1.23.1  [45397f5d] + UnitfulLatexify v1.7.0  [41fe7b60] + Unzip v0.2.0  [6e34b625] + Bzip2_jll v1.0.9+0  [83423d85] + Cairo_jll v1.18.5+0  [ee1fde0b] + Dbus_jll v1.16.2+0  [2702e6a9] + EpollShim_jll v0.0.20230411+1  [2e619515] + Expat_jll v2.6.5+0  [b22a6f82] + FFMPEG_jll v4.4.4+1  [a3f928ae] + Fontconfig_jll v2.16.0+0  [d7e528f0] + FreeType2_jll v2.13.4+0  [559328eb] + FriBidi_jll v1.0.17+0  [0656b61e] + GLFW_jll v3.4.0+2  [d2c73de3] + GR_jll v0.73.6+0  [78b55507] + Gettext_jll v0.21.0+0  [7746bdde] + Glib_jll v2.84.0+0  [3b182d85] + Graphite2_jll v1.3.15+0  [2e76f6c2] + HarfBuzz_jll v8.5.1+0  [aacddb02] + JpegTurbo_jll v3.1.1+0  [c1c5ebd0] + LAME_jll v3.100.2+0  [88015f11] + LERC_jll v3.0.0+1  [1d63c593] + LLVMOpenMP_jll v18.1.8+0  [dd4b983a] + LZO_jll v2.10.3+0  [e9f186c6] + Libffi_jll v3.4.7+0  [7e76a0d4] + Libglvnd_jll v1.7.1+1  [94ce4f54] + Libiconv_jll v1.18.0+0  [4b2f31a3] + Libmount_jll v2.41.0+0  [89763e89] + Libtiff_jll v4.5.1+1  [38a345b3] + Libuuid_jll v2.41.0+0  [e7412a2a] + Ogg_jll v1.3.5+1  [458c3c95] + OpenSSL_jll v3.5.0+0  [91d4177d] + Opus_jll v1.3.3+0  [36c8627f] + Pango_jll v1.56.3+0  [30392449] + Pixman_jll v0.44.2+0  [c0090381] + Qt6Base_jll v6.7.1+1  [a44049a8] + Vulkan_Loader_jll v1.3.243+0  [a2964d1f] + Wayland_jll v1.23.1+0  [2381bf8a] + Wayland_protocols_jll v1.44.0+0  [02c8fc9c] + XML2_jll v2.13.6+1  [ffd25f8a] + XZ_jll v5.8.1+0  [f67eecfb] + Xorg_libICE_jll v1.1.2+0  [c834827a] + Xorg_libSM_jll v1.2.6+0  [4f6342f7] + Xorg_libX11_jll v1.8.12+0  [0c0b7dd1] + Xorg_libXau_jll v1.0.13+0  [935fb764] + Xorg_libXcursor_jll v1.2.4+0  [a3789734] + Xorg_libXdmcp_jll v1.1.6+0  [1082639a] + Xorg_libXext_jll v1.3.7+0  [d091e8ba] + Xorg_libXfixes_jll v6.0.1+0  [a51aa0fd] + Xorg_libXi_jll v1.8.3+0  [d1454406] + Xorg_libXinerama_jll v1.1.6+0  [ec84b674] + Xorg_libXrandr_jll v1.5.5+0  [ea2f1a96] + Xorg_libXrender_jll v0.9.12+0  [c7cfdc94] + Xorg_libxcb_jll v1.17.1+0  [cc61e674] + Xorg_libxkbfile_jll v1.1.3+0  [e920d4aa] + Xorg_xcb_util_cursor_jll v0.1.4+0  [12413925] + Xorg_xcb_util_image_jll v0.4.1+0  [2def613f] + Xorg_xcb_util_jll v0.4.1+0  [975044d2] + Xorg_xcb_util_keysyms_jll v0.4.1+0  [0d47668e] + Xorg_xcb_util_renderutil_jll v0.3.10+0  [c22f9ab0] + Xorg_xcb_util_wm_jll v0.4.2+0  [35661453] + Xorg_xkbcomp_jll v1.4.7+0  [33bec58e] + Xorg_xkeyboard_config_jll v2.44.0+0  [c5fb5394] + Xorg_xtrans_jll v1.6.0+0  [3161d3a3] + Zstd_jll v1.5.7+1  [35ca27e7] + eudev_jll v3.2.14+0  [214eeab7] + fzf_jll v0.61.1+0  [a4ae2306] + libaom_jll v3.11.0+0  [0ac62f75] + libass_jll v0.15.2+0  [1183f4f0] + libdecor_jll v0.2.2+0  [2db6ffa8] + libevdev_jll v1.13.4+0  [f638f0a6] + libfdk_aac_jll v2.0.3+0  [36db933b] + libinput_jll v1.28.1+0  [b53b4c65] + libpng_jll v1.6.49+0  [f27f6e37] + libvorbis_jll v1.3.7+2  [009596ad] + mtdev_jll v1.1.7+0  [1270edf5] + x264_jll v2021.5.5+0  [dfaa095f] + x265_jll v3.5.0+0  [d8fb68d0] + xkbcommon_jll v1.8.1+0  [0dad84c5] + ArgTools  [56f22d72] + Artifacts  [2a0f44e3] + Base64  [ade2ca70] + Dates  [8bb1440f] + DelimitedFiles  [f43a241f] + Downloads  [7b1f6079] + FileWatching  [b77e0a4c] + InteractiveUtils  [b27032c2] + LibCURL  [76f85450] + LibGit2  [8f399da3] + Libdl  [37e2e46d] + LinearAlgebra  [56ddb016] + Logging  [d6f4376e] + Markdown  [a63ad114] + Mmap  [ca575930] + NetworkOptions  [44cfe95a] + Pkg  [de0858da] + Printf  [3fa0cd96] + REPL  [9a3f8284] + Random  [ea8e919c] + SHA  [9e88b42a] + Serialization  [6462fe0b] + Sockets  [2f01184e] + SparseArrays  [10745b16] + Statistics  [fa267f1f] + TOML  [a4e569a6] + Tar  [8dfed614] + Test  [cf7118a7] + UUIDs  [4ec0a83e] + Unicode  [e66e0078] + CompilerSupportLibraries_jll  [deac9b47] + LibCURL_jll  [29816b5a] + LibSSH2_jll  [c8ffd9c3] + MbedTLS_jll  [14a3606d] + MozillaCACerts_jll  [4536629a] + OpenBLAS_jll  [05823500] + OpenLibm_jll  [efcefdf7] + PCRE2_jll  [83775a58] + Zlib_jll  [8e850b90] + libblastrampoline_jll  [8e850ede] + nghttp2_jll  [3f19e933] + p7zip_jll text/plaincell_id$15187690-0403-11eb-2dfd-fd924faa3513kwargsidPlutoRunner_d1acb81efileP/home/runner/.julia/packages/Pluto/6smog/src/runner/PlutoRunner/src/io/stdout.jlgroupstdoutlevelLogLevel(-555)running¦outputbodymimetext/plainrootassigneelast_run_timestampAIpersist_js_state·has_pluto_hook_features§cell_id$15187690-0403-11eb-2dfd-fd924faa3513depends_on_disabled_cells§runtime I/published_object_keysdepends_on_skipped_cells§errored$d8abd2f6-0416-11eb-1c2a-f9157d9760a7queued¤logsrunning¦outputbodymissingmimetext/plainrootassigneesmall_experimentlast_run_timestampAɲIpersist_js_state·has_pluto_hook_features§cell_id$d8abd2f6-0416-11eb-1c2a-f9157d9760a7depends_on_disabled_cells§runtime7published_object_keysdepends_on_skipped_cells§errored$9374e63c-0493-11eb-0952-4b97512d7cdbqueued¤logsrunning¦outputbody

Great! Feel free to experiment with this function, try giving it a different array as argument. Plots.jl is pretty clever, it even works with an array of strings!

Exercise 1.4

Next, we want to add a new element to our plot: a vertical line. To demonstrate how this works, here we added a vertical line at the maximum value.

To write this function, we first create a base plot, we then modify that plot to add the vertical line, and finally, we return the plot. More on this in the next info box.

mimetext/htmlrootassigneelast_run_timestampAqXpersist_js_state·has_pluto_hook_features§cell_id$9374e63c-0493-11eb-0952-4b97512d7cdbdepends_on_disabled_cells§runtimew.published_object_keysdepends_on_skipped_cells§errored$2d3bba2a-04a8-11eb-2c40-87794b6aeeacqueued¤logsrunning¦outputbodyy

Exercise 2.5

👉 Write a function interact! that takes an affected agent of type Agent, an source of type Agent and an infection of type InfectionRecovery. It implements a single (one-sided) interaction between two agents:

mimetext/htmlrootassigneelast_run_timestampAs!persist_js_state·has_pluto_hook_features§cell_id$2d3bba2a-04a8-11eb-2c40-87794b6aeeacdepends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$dfb99ace-04cf-11eb-0739-7d694c837d59queued¤logsrunning¦outputbody

👉 Allow $p_\text{infection}$ and $p_\text{recovery}$ to be changed interactively and find parameter values for which you observe an epidemic outbreak.

mimetext/htmlrootassigneelast_run_timestampAvpersist_js_state·has_pluto_hook_features§cell_id$dfb99ace-04cf-11eb-0739-7d694c837d59depends_on_disabled_cells§runtime2Spublished_object_keysdepends_on_skipped_cells§errored$271ec5f0-041d-11eb-041b-db46ec1465e0queued¤logsrunning¦outputbodyN

We have just defined a new type InfectionStatus, as well as names S, I and R that are the (only) possible values that a variable of this type can take.

👉 Define a variable test_status whose value is S.

mimetext/htmlrootassigneelast_run_timestampArpersist_js_state·has_pluto_hook_features§cell_id$271ec5f0-041d-11eb-041b-db46ec1465e0depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$7946d83a-04a0-11eb-224b-2b315e87bc84queued¤logsrunning¦outputbody0generate_agents (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAʫpersist_js_state·has_pluto_hook_features§cell_id$7946d83a-04a0-11eb-224b-2b315e87bc84depends_on_disabled_cells§runtimeipublished_object_keysdepends_on_skipped_cells§errored$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9queued¤logsrunning¦outputbody*bernoulli (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAɇipersist_js_state·has_pluto_hook_features§cell_id$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$9635c944-0403-11eb-3982-4df509f6a556queued¤logsrunning¦outputbody

Exercse 3.4

👉 What are three simple ways in which you could characterise the magnitude (size) of the epidemic outbreak? Find approximate values of these quantities for one of the runs of your simulation.

mimetext/htmlrootassigneelast_run_timestampAvpersist_js_state·has_pluto_hook_features§cell_id$9635c944-0403-11eb-3982-4df509f6a556depends_on_disabled_cells§runtimef?published_object_keysdepends_on_skipped_cells§errored$f3f81172-041c-11eb-2b9b-e99b7b9400edqueued¤logsrunning¦outputbody

Note about plotting

Plots.jl has an interesting property: a plot is an object, not an action. Functions like plot, bar, histogram don't draw anything on your screen - they just return a Plots.Plot. This is a struct that contains the description of a plot (what data should be plotted in what way?), not the picture.

So a Pluto cell with a single line, plot(1:10), will show a plot, because the result of the function plot is a Plot object, and Pluto just shows the result of a cell.

Modifying plots

Nice plots are often formed by overlaying multiple plots. In Plots.jl, this is done using the modifying functions: plot!, bar!, vline!, etc. These take an extra (first) argument: a previous plot to modify.

For example, to plot the sin, cos and tan functions in the same view, we do:

function sin_cos_plot()
    T = -1.0:0.01:1.0
    
    result = plot(T, sin.(T))
    plot!(result, T, cos.(T))
    plot!(result, T, tan.(T))

    return result
end

💡 This example demonstrates a useful pattern to combine plots:

  1. Create a new plot and store it in a variable

  2. Modify that plot to add more elements

  3. Return the plot

It is recommended that these 3 steps happen within a single cell. This can prevent some strange glitches when re-running cells. There are three ways to group expressions together into a single cell: begin, let and function. More on this later!

mimetext/htmlrootassigneelast_run_timestampAqvpersist_js_state·has_pluto_hook_features§cell_id$f3f81172-041c-11eb-2b9b-e99b7b9400eddepends_on_disabled_cells§runtime9published_object_keysdepends_on_skipped_cells§errored$4ad11052-042c-11eb-3643-8b2b3e1269bcqueued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAvpersist_js_state·has_pluto_hook_features§cell_id$4ad11052-042c-11eb-3643-8b2b3e1269bcdepends_on_disabled_cells§runtime!published_object_keysdepends_on_skipped_cells§errored$76d117d4-0403-11eb-05d2-c5ea47d06f43queued¤logsrunning¦outputbodyٗ

👉 Write a function recovery_time(p) that returns the time taken until the person recovers.

mimetext/htmlrootassigneelast_run_timestampApFpersist_js_state·has_pluto_hook_features§cell_id$76d117d4-0403-11eb-05d2-c5ea47d06f43depends_on_disabled_cells§runtimeppublished_object_keysdepends_on_skipped_cells§errored$095cbf46-0403-11eb-0c37-35de9562cebcqueued¤logsrunning¦outputbodyelementsname"Jazzy Doe"text/plainkerberos_id"jazz"text/plaintypeNamedTupleobjectideb71b675ed8a366bmime!application/vnd.pluto.tree+objectrootassigneestudentlast_run_timestampA@-persist_js_state·has_pluto_hook_features§cell_id$095cbf46-0403-11eb-0c37-35de9562cebcdepends_on_disabled_cells§runtimeOpublished_object_keysdepends_on_skipped_cells§errored$26e2978e-0435-11eb-0d61-25f552d2771equeued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAvlrpersist_js_state·has_pluto_hook_features§cell_id$26e2978e-0435-11eb-0d61-25f552d2771edepends_on_disabled_cells§runtime)published_object_keysdepends_on_skipped_cells§errored$6de37d6c-0415-11eb-1b05-85ac820016c7queued¤logsrunning¦outputbody^

👉 What happens for $p=1$?

mimetext/htmlrootassigneelast_run_timestampApCpersist_js_state·has_pluto_hook_features§cell_id$6de37d6c-0415-11eb-1b05-85ac820016c7depends_on_disabled_cells§runtimezpublished_object_keysdepends_on_skipped_cells§errored$18d308c4-0424-11eb-176d-49feec6889cfqueued¤logsrunning¦outputbodymissingmimetext/plainrootassigneetest_agentlast_run_timestampA{ݔpersist_js_state·has_pluto_hook_features§cell_id$18d308c4-0424-11eb-176d-49feec6889cfdepends_on_disabled_cells§runtime.ϵpublished_object_keysdepends_on_skipped_cells§errored$46133a74-04b1-11eb-0b46-0bc74e564680queued¤logsrunning¦outputbody'sweep! (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampApersist_js_state·has_pluto_hook_features§cell_id$46133a74-04b1-11eb-0b46-0bc74e564680depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$771c8f0c-0403-11eb-097e-ab24d0714ad5queued¤logsrunning¦outputbody@

Exercise 1.3

👉 Write a function frequencies(data) that calculates and returns the frequencies (i.e. probability distribution) of input data.

The input will be an array of integers, with duplicates, and the result will be a dictionary that maps each occured value to its frequency in the data.

For example,

frequencies([7, 8, 9, 7])

should give

Dict(
	7 => 0.5, 
	8 => 0.25, 
	9 => 0.25
)

As with any probability distribution, it should be normalised to $1$, in the sense that the total probability should be $1$.

mimetext/htmlrootassigneelast_run_timestampAqpersist_js_state·has_pluto_hook_features§cell_id$771c8f0c-0403-11eb-097e-ab24d0714ad5depends_on_disabled_cells§runtimeRpublished_object_keysdepends_on_skipped_cells§errored$80c2cd88-04b1-11eb-326e-0120a39405eaqueued¤logsrunning¦outputbodyprefix:NamedTuple{(:S, :I, :R), Tuple{Missing, Missing, Missing}}elementselementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+object elementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+object elementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+object elementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+object elementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+object elementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objectelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2!application/vnd.pluto.tree+objecttypeArrayprefix_shortobjectidcf2b1d28459da63fmime!application/vnd.pluto.tree+objectrootassigneesimulationslast_run_timestampA`2persist_js_state·has_pluto_hook_features§cell_id$80c2cd88-04b1-11eb-326e-0120a39405eadepends_on_disabled_cells§runtimeCpublished_object_keysdepends_on_skipped_cells§errored$105d347e-041c-11eb-2fc8-1d9e5eda2be0queued¤logsrunning¦outputbody,frequencies (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAɼμpersist_js_state·has_pluto_hook_features§cell_id$105d347e-041c-11eb-2fc8-1d9e5eda2be0depends_on_disabled_cells§runtime_Opublished_object_keysdepends_on_skipped_cells§errored$2c62b4ae-04b3-11eb-0080-a1035a7e31a2queued¤logsrunning¦outputbodyelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2mime!application/vnd.pluto.tree+objectrootassigneelast_run_timestampAȨpersist_js_state·has_pluto_hook_features§cell_id$2c62b4ae-04b3-11eb-0080-a1035a7e31a2depends_on_disabled_cells§runtime͍published_object_keysdepends_on_skipped_cells§errored$6db6c894-0415-11eb-305a-c75b119d89e9queued¤logsrunning¦outputbody

We should always be aware of special cases (sometimes called "boundary conditions"). Make sure not to run the code with $p=0$! What would happen in that case? Your code should check for this and throw an ArgumentError as follows:

throw(ArgumentError("..."))  

with a suitable error message.

mimetext/htmlrootassigneelast_run_timestampAppersist_js_state·has_pluto_hook_features§cell_id$6db6c894-0415-11eb-305a-c75b119d89e9depends_on_disabled_cells§runtimeq˵published_object_keysdepends_on_skipped_cells§errored$77db111e-0403-11eb-2dea-4b42ceed65d6queued¤logsrunning¦outputbodyl

Exercise 1.6

👉 Use $N = 10,000$ to calculate the mean time $\langle \tau(p) \rangle$ to recover as a function of $p$ between $0.001$ and $1$ (say). Plot this relationship.

mimetext/htmlrootassigneelast_run_timestampAr)=persist_js_state·has_pluto_hook_features§cell_id$77db111e-0403-11eb-2dea-4b42ceed65d6depends_on_disabled_cells§runtime$published_object_keysdepends_on_skipped_cells§errored$3d88c056-0414-11eb-0025-05d3aff1588bqueued¤logsrunning¦outputbody)correct (generic function with 2 methods)mimetext/plainrootassigneelast_run_timestampA@t%persist_js_state·has_pluto_hook_features§cell_id$3d88c056-0414-11eb-0025-05d3aff1588bdepends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$287ee7aa-0435-11eb-0ca3-951dbbe69404queued¤logsrunning¦outputbody4sir_mean_error_plot (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAkpersist_js_state·has_pluto_hook_features§cell_id$287ee7aa-0435-11eb-0ca3-951dbbe69404depends_on_disabled_cells§runtime Mĵpublished_object_keysdepends_on_skipped_cells§errored$03a85970-0403-11eb-334a-812b59c0905bqueued¤logsrunning¦outputbodym

Submission by: Jazzy Doe (jazz@mit.edu)

mimetext/htmlrootassigneelast_run_timestampAy0 persist_js_state·has_pluto_hook_features§cell_id$03a85970-0403-11eb-334a-812b59c0905bdepends_on_disabled_cells§runtime%published_object_keysdepends_on_skipped_cells§errored$6d906d0c-0415-11eb-0c1c-b5c0aca841dbqueued¤logsrunning¦outputbody

Hint

Remember to always re-use work you have done previously: in this case you should re-use the function bernoulli.

mimetext/htmlrootassigneelast_run_timestampA persist_js_state·has_pluto_hook_features§cell_id$6d906d0c-0415-11eb-0c1c-b5c0aca841dbdepends_on_disabled_cells§runtime/published_object_keysdepends_on_skipped_cells§errored$866299e8-0403-11eb-085d-2b93459cc141queued¤logsrunning¦outputbodyٸ

👉 We will also need functions is_susceptible and is_infected that check if a given agent is in those respective states.

mimetext/htmlrootassigneelast_run_timestampAsvlpersist_js_state·has_pluto_hook_features§cell_id$866299e8-0403-11eb-085d-2b93459cc141depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$461586dc-0414-11eb-00f3-4984b57bfac5queued¤logsrunning¦outputbody'almost (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampANUpersist_js_state·has_pluto_hook_features§cell_id$461586dc-0414-11eb-00f3-4984b57bfac5depends_on_disabled_cells§runtimeεpublished_object_keysdepends_on_skipped_cells§errored$c5156c72-04af-11eb-1106-b13969b036caqueued¤logsrunning¦outputbodymsg2Cannot convert Missing to series data for plottingstacktracecall_shorterror(s::String)inlined£urlbhttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/error.jl#L33path./error.jlsource_packagecallerror(s::String)linfo_typeCore.MethodInstanceline!fileerror.jlfuncerrorparent_modulefrom_cŒcall_short _prepare_series_data(x::Missing)inlined£urlGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecall _prepare_series_data(x::Missing)linfo_typeCore.MethodInstancelinefileseries.jlfunc_prepare_series_dataparent_modulefrom_cŒcall_shortB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})inlined£urlGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecallB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})linfo_typeCore.MethodInstanceline$fileseries.jlfunc_series_data_vectorparent_modulefrom_cŒcall_shortmacro expansioninlinedãurlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecallmacro expansionlinfo_typeNothinglinéfileseries.jlfuncmacro expansionparent_modulefrom_cŒcall_shortxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)inlined£urlHfile:///home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlpathA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlsource_packagecallxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)linfo_typeCore.MethodInstanceline,fileRecipesBase.jlfuncapply_recipeparent_modulefrom_cŒcall_short?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)inlined£urlLfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jlpathE/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jlsource_packagecall?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)linfo_typeCore.MethodInstanceline&fileuser_recipe.jlfunc_process_userrecipes!parent_modulefrom_cŒcall_short:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)inlined£urlPfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jlpathI/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jlsource_packagecall:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)linfo_typeCore.MethodInstancelineHfileRecipesPipeline.jlfuncrecipe_pipeline!parent_modulefrom_cŒcall_short7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)inlined£url;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jlpath4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jlsource_packagecall7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)linfo_typeCore.MethodInstancelineߤfileplot.jlfunc_plot!parent_modulefrom_cŒcall_short#plot#186inlinedãurlpath4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jlsource_packagecall#plot#186linfo_typeNothinglineffileplot.jlfunc#plot#186parent_modulefrom_cŒcall_shorttop-level scopeinlinedãurlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#c5156c72-04af-11eb-1106-b13969b036casource_packagecalltop-level scopelinfo_typeNothinglinefile.hw4.jl#==#c5156c72-04af-11eb-1106-b13969b036cafunc##function_wrapped_cell#396parent_modulefrom_c¤mime'application/vnd.pluto.stacktrace+objectrootassigneelast_run_timestampA9persist_js_state·has_pluto_hook_features§cell_id$c5156c72-04af-11eb-1106-b13969b036cadepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$c4a8694a-04d4-11eb-1eef-c9e037e6b21fqueued¤logsrunning¦outputbody٥

Here we go!

Replace missing with your answer.

mimetext/htmlrootassigneelast_run_timestampAWpersist_js_state·has_pluto_hook_features§cell_id$c4a8694a-04d4-11eb-1eef-c9e037e6b21fdepends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$1491a078-04aa-11eb-0106-19a3cf1e94b0queued¤logsrunning¦outputbody

Keep working on it!

The agent should recover from an infectious state with the right probability.

mimetext/htmlrootassigneelast_run_timestampAeȽpersist_js_state·has_pluto_hook_features§cell_id$1491a078-04aa-11eb-0106-19a3cf1e94b0depends_on_disabled_cells§runtimehpublished_object_keysdepends_on_skipped_cells§errored$c5c7cb86-041b-11eb-3360-45463105f3c9queued¤logsrunning¦outputbody.do_experiment (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAɤpersist_js_state·has_pluto_hook_features§cell_id$c5c7cb86-041b-11eb-3360-45463105f3c9depends_on_disabled_cells§runtime,published_object_keysdepends_on_skipped_cells§errored$01341648-0403-11eb-2212-db450c299f35queued¤logsrunning¦outputbodyB

homework 4, version 1

mimetext/htmlrootassigneelast_run_timestampAp=persist_js_state·has_pluto_hook_features§cell_id$01341648-0403-11eb-2212-db450c299f35depends_on_disabled_cells§runtime@published_object_keysdepends_on_skipped_cells§errored$48a16c42-0414-11eb-0e0c-bf52bbb0f618queued¤logsrunning¦outputbody%hint (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampA:persist_js_state·has_pluto_hook_features§cell_id$48a16c42-0414-11eb-0e0c-bf52bbb0f618depends_on_disabled_cells§runtimespublished_object_keysdepends_on_skipped_cells§errored$98beb336-0425-11eb-3886-4f8cfd210288queued¤logsrunning¦outputbody,set_status! (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAʌkpersist_js_state·has_pluto_hook_features§cell_id$98beb336-0425-11eb-3886-4f8cfd210288depends_on_disabled_cells§runtimečpublished_object_keysdepends_on_skipped_cells§errored$bb63f3cc-042f-11eb-04ff-a128aec3c378queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAqʧpersist_js_state·has_pluto_hook_features§cell_id$bb63f3cc-042f-11eb-04ff-a128aec3c378depends_on_disabled_cells§runtimeYpublished_object_keysdepends_on_skipped_cells§errored$61c00724-0403-11eb-228d-17c11670e5d1queued¤logsrunning¦outputbody

Exercise 4: Reinfection

In this exercise we will re-use our simulation infrastructure to study the dynamics of a different type of infection: there is no immunity, and hence no "recovery" rather, susceptible individuals may now be re-infected

Exercise 4.1

👉 Make a new infection type Reinfection. This has the same two fields as InfectionRecovery (p_infection and p_recovery). However, "recovery" now means "becomes susceptible again", instead of "moves to the R class.

This new type Reinfection should also be a subtype of AbstractInfection. This allows us to reuse our previous functions, which are defined for the abstract supertype.

mimetext/htmlrootassigneelast_run_timestampAvVpersist_js_state·has_pluto_hook_features§cell_id$61c00724-0403-11eb-228d-17c11670e5d1depends_on_disabled_cells§runtime Gpublished_object_keysdepends_on_skipped_cells§errored$9cf9080a-04b1-11eb-12a0-17013f2d37f5queued¤logsrunning¦outputbody,

👉 Calculate the mean number of infectious agents of our simulations for each time step. Add it to the plot using a heavier line (lw=3 for "linewidth") by modifying the cell above.

Check the answer yourself: does your curve follow the average trend?

Hint

This exercise requires some creative juggling with arrays, anonymous functions, maps, or whatever you see fit!

mimetext/htmlrootassigneelast_run_timestampA Ǭpersist_js_state·has_pluto_hook_features§cell_id$9cf9080a-04b1-11eb-12a0-17013f2d37f5depends_on_disabled_cells§runtimeg;published_object_keysdepends_on_skipped_cells§errored$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8queued¤logsrunning¦outputbodymissingmimetext/plainrootassigneelarge_experimentlast_run_timestampAɾKpersist_js_state·has_pluto_hook_features§cell_id$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8depends_on_disabled_cells§runtime6ʵpublished_object_keysdepends_on_skipped_cells§errored$61789646-0403-11eb-0042-f3b8308f11baqueued¤logsrunning¦outputbody3

Exercise 2: Agent-based model for an epidemic outbreak – types

In this and the following exercises we will develop a simple stochastic model for combined infection and recovery in a population, which may exhibit an epidemic outbreak (i.e. a large spike in the number of infectious people). The population is well mixed, i.e. everyone is in contact with everyone else. [An example of this would be a small school or university in which people are constantly moving around and interacting with each other.]

The model is an individual-based or agent-based model: we explicitly keep track of each individual, or agent, in the population and their infection status. For the moment we will not keep track of their position in space; we will just assume that there is some mechanism, not included in the model, by which they interact with other individuals.

Exercise 2.1

Each agent will have its own internal state, modelling its infection status, namely "susceptible", "infectious" or "recovered". We would like to code these as values S, I and R, respectively. One way to do this is using an enumerated type or enum. Variables of this type can take only a pre-defined set of values; the Julia syntax is as follows:

mimetext/htmlrootassigneelast_run_timestampArfIpersist_js_state·has_pluto_hook_features§cell_id$61789646-0403-11eb-0042-f3b8308f11badepends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$39dffa3c-0414-11eb-0197-e72b299e9c63queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAnBհpersist_js_state·has_pluto_hook_features§cell_id$39dffa3c-0414-11eb-0197-e72b299e9c63depends_on_disabled_cells§runtime͂published_object_keysdepends_on_skipped_cells§errored$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272queued¤logsrunning¦outputbody

Got it!

Your function treats the recovered agent case correctly!

mimetext/htmlrootassigneelast_run_timestampAiѰpersist_js_state·has_pluto_hook_features§cell_id$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272depends_on_disabled_cells§runtimeHpublished_object_keysdepends_on_skipped_cells§errored$88c53208-041d-11eb-3b1e-31b57ba99f05queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampArCpersist_js_state·has_pluto_hook_features§cell_id$88c53208-041d-11eb-3b1e-31b57ba99f05depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$887d27fc-04bc-11eb-0ab9-eb95ef9607f8queued¤logsrunning¦outputbody+simulation (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampA߰persist_js_state·has_pluto_hook_features§cell_id$887d27fc-04bc-11eb-0ab9-eb95ef9607f8depends_on_disabled_cells§runtimez|published_object_keysdepends_on_skipped_cells§errored$d57c6a5a-041b-11eb-3ab4-774a2d45a891queued¤logsrunning¦outputbody.recovery_time (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAɓ*xpersist_js_state·has_pluto_hook_features§cell_id$d57c6a5a-041b-11eb-3ab4-774a2d45a891depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$12cc2940-0403-11eb-19a7-bb570de58f6fqueued¤logslinemsg@ Activating new project at `/tmp/jl_tSReBH` text/plaincell_id$12cc2940-0403-11eb-19a7-bb570de58f6fkwargsidPlutoRunner_d1acb81efileP/home/runner/.julia/packages/Pluto/6smog/src/runner/PlutoRunner/src/io/stdout.jlgroupstdoutlevelLogLevel(-555)running¦outputbodymimetext/plainrootassigneelast_run_timestampAƟpersist_js_state·has_pluto_hook_features§cell_id$12cc2940-0403-11eb-19a7-bb570de58f6fdepends_on_disabled_cells§runtimeYHߵpublished_object_keysdepends_on_skipped_cells§errored$76f62d64-0403-11eb-27e2-3de58366b619queued¤logsrunning¦outputbody

Exercise 1.2

👉 Write a function do_experiment(p, N) that runs the function recovery_time N times and collects the results into a vector.

mimetext/htmlrootassigneelast_run_timestampAp2persist_js_state·has_pluto_hook_features§cell_id$76f62d64-0403-11eb-27e2-3de58366b619depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$860790fc-0403-11eb-2f2e-355f77dcc7afqueued¤logsrunning¦outputbodyL

Exercise 2.2

For each agent we want to keep track of its infection status and the number of other agents that it infects during the simulation. A good solution for this is to define a new type Agent to hold all of the information for one agent, as follows:

mimetext/htmlrootassigneelast_run_timestampAr޹persist_js_state·has_pluto_hook_features§cell_id$860790fc-0403-11eb-2f2e-355f77dcc7afdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$b21475c6-04ac-11eb-1366-f3b5e967402dqueued¤logsrunning¦outputbody

Play around with the test case below to test your function! Try changing the definitions of agent, source and infection. Since we are working with randomness, you might want to run the cell multiple times.

mimetext/htmlrootassigneelast_run_timestampAspersist_js_state·has_pluto_hook_features§cell_id$b21475c6-04ac-11eb-1366-f3b5e967402ddepends_on_disabled_cells§runtimeQpublished_object_keysdepends_on_skipped_cells§errored$823364ce-041c-11eb-2467-7ffa4f751527queued¤logsrunning¦outputbody>frequencies_plot_with_maximum (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampA@persist_js_state·has_pluto_hook_features§cell_id$823364ce-041c-11eb-2467-7ffa4f751527depends_on_disabled_cells§runtime 1published_object_keysdepends_on_skipped_cells§errored$619c8a10-0403-11eb-2e89-8b0974fb01d0queued¤logsrunning¦outputbody

Exercise 3: Agent-based model for an epidemic outbreak – Monte Carlo simulation

In this exercise we will build on Exercise 2 to write a Monte Carlo simulation of how an infection propagates in a population.

Make sure to re-use the functions that we have already written, and introduce new ones if they are helpful! Short functions make it easier to understand what the function does and build up new functionality piece by piece.

You should not use any global variables inside the functions: Each function must accept as arguments all the information it requires to carry out its task. You need to think carefully about what the information each function requires.

Exercise 3.1

👉 Write a function step! that takes a vector of Agents and an infection of type InfectionRecovery. It implements a single step of the infection dynamics as follows:

mimetext/htmlrootassigneelast_run_timestampAtpersist_js_state·has_pluto_hook_features§cell_id$619c8a10-0403-11eb-2e89-8b0974fb01d0depends_on_disabled_cells§runtimeVpublished_object_keysdepends_on_skipped_cells§errored$38b1aa5a-04cf-11eb-11a2-930741fc9076queued¤logsrunning¦outputbody3repeat_simulations (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampABհpersist_js_state·has_pluto_hook_features§cell_id$38b1aa5a-04cf-11eb-11a2-930741fc9076depends_on_disabled_cells§runtimem&published_object_keysdepends_on_skipped_cells§errored$8dd97820-04a5-11eb-36c0-8f92d4b859a8queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAvpersist_js_state·has_pluto_hook_features§cell_id$8dd97820-04a5-11eb-36c0-8f92d4b859a8depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$df8547b4-0400-11eb-07c6-fb370b61c2b6queued¤logsrunning¦outputbodyP

Exercise 1: Modelling recovery

In this exercise we will investigate a simple stochastic (probabilistic) model of recovery from an infection and the time $\tau$ needed to recover. Although this model can be easily studied analytically using probability theory, we will instead use computational methods. (If you know about this distribution already, try to ignore what you know about it!)

In this model, an individual who is infected has a constant probability $p$ to recover each day. If they recover on day $n$ then $\tau$ takes the value $n$. Each time we run a new experiment $\tau$ will take on different values, so $\tau$ is a (discrete) random variable. We thus need to study statistical properties of $\tau$, such as its mean and its probability distribution.

Exercise 1.1 - Probability distributions

👉 Define the function bernoulli(p), which returns true with probability $p$ and false with probability $(1 - p)$.

mimetext/htmlrootassigneelast_run_timestampApǰpersist_js_state·has_pluto_hook_features§cell_id$df8547b4-0400-11eb-07c6-fb370b61c2b6depends_on_disabled_cells§runtime&published_object_keysdepends_on_skipped_cells§errored$1d3356c4-0403-11eb-0f48-01b5eb14a585queued¤logsrunning¦outputbody mimetext/htmlrootassigneelast_run_timestampAp^persist_js_state·has_pluto_hook_features§cell_id$1d3356c4-0403-11eb-0f48-01b5eb14a585depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$82f2580a-04c8-11eb-1eea-bdb4e50eee3bqueued¤logsrunning¦outputbodymsgMethodError: no method matching Main.workspace#4.Agent() Closest candidates are:  Main.workspace#4.Agent(::Main.workspace#4.InfectionStatus, ::Int64) at ~/work/disorganised-mess/disorganised-mess/hw4.jl#==#ae4ac4b4-041f-11eb-14f5-1bcde35d18f2:2  Main.workspace#4.Agent(::Any, ::Any) at ~/work/disorganised-mess/disorganised-mess/hw4.jl#==#ae4ac4b4-041f-11eb-14f5-1bcde35d18f2:2stacktracecall_shorttop-level scopeinlinedãurlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#82f2580a-04c8-11eb-1eea-bdb4e50eee3bsource_packagecalltop-level scopelinfo_typeNothinglinefile.hw4.jl#==#82f2580a-04c8-11eb-1eea-bdb4e50eee3bfunc##function_wrapped_cell#354parent_modulefrom_c¤mime'application/vnd.pluto.stacktrace+objectrootassigneelast_run_timestampAʁpersist_js_state·has_pluto_hook_features§cell_id$82f2580a-04c8-11eb-1eea-bdb4e50eee3bdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$86d98d0a-0403-11eb-215b-c58ad721a90bqueued¤logsrunning¦outputbody

We will also need types representing different infections.

Let's define an (immutable) struct called InfectionRecovery with parameters p_infection and p_recovery. We will make it a subtype of an abstract AbstractInfection type, because we will define more infection types later.

mimetext/htmlrootassigneelast_run_timestampAspersist_js_state·has_pluto_hook_features§cell_id$86d98d0a-0403-11eb-215b-c58ad721a90bdepends_on_disabled_cells§runtime)Gpublished_object_keysdepends_on_skipped_cells§errored$dc784864-0430-11eb-1478-d1153e017310queued¤logsrunning¦outputbody

The frequencies dictionary is difficult to interpret on its own, so instead, we will plot it, i.e. plot $P(\tau = n)$ against $n$, where $n$ is the recovery time.

Plots.jl comes with a function bar, which does exactly what we want:

mimetext/htmlrootassigneelast_run_timestampAq6persist_js_state·has_pluto_hook_features§cell_id$dc784864-0430-11eb-1478-d1153e017310depends_on_disabled_cells§runtimeSpublished_object_keysdepends_on_skipped_cells§errored$3f5e0af8-0414-11eb-34a7-a71e7aaf6443queued¤logsrunning¦outputbodyprefixMarkdown.MDelements2

Fantastic!

text/html1

Splendid!

text/html.

Great!

text/html+

Yay ❤

text/html3

Great! 🎉

text/html2

Well done!

text/html3

Keep it up!

text/html1

Good job!

text/html 0

Awesome!

text/html A

You got the right answer!

text/html J

Let's move on to the next section.

text/htmltypeArrayprefix_shortobjectid7e19e2361e36a1abmime!application/vnd.pluto.tree+objectrootassigneeyayslast_run_timestampA5persist_js_state·has_pluto_hook_features§cell_id$3f5e0af8-0414-11eb-34a7-a71e7aaf6443depends_on_disabled_cells§runtimeA#published_object_keysdepends_on_skipped_cells§errored$3c0528a0-0414-11eb-2f68-a5657ab9e73dqueued¤logsrunning¦outputbody,not_defined (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAK

Here we go!

Replace missing with your answer.

mimetext/htmlrootassigneelast_run_timestampAUpersist_js_state·has_pluto_hook_features§cell_id$c61f35ea-04d6-11eb-2503-17a79f8d0298depends_on_disabled_cells§runtimeUApublished_object_keysdepends_on_skipped_cells§errored$9cd2bb00-04b1-11eb-1d83-a703907141a7queued¤logsrunning¦outputbodymsg2Cannot convert Missing to series data for plottingstacktracecall_shorterror(s::String)inlined£urlbhttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/error.jl#L33path./error.jlsource_packagecallerror(s::String)linfo_typeCore.MethodInstanceline!fileerror.jlfuncerrorparent_modulefrom_cŒcall_short _prepare_series_data(x::Missing)inlined£urlGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecall _prepare_series_data(x::Missing)linfo_typeCore.MethodInstancelinefileseries.jlfunc_prepare_series_dataparent_modulefrom_cŒcall_shortB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})inlined£urlGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecallB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})linfo_typeCore.MethodInstanceline$fileseries.jlfunc_series_data_vectorparent_modulefrom_cŒcall_shortmacro expansioninlinedãurlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecallmacro expansionlinfo_typeNothinglinéfileseries.jlfuncmacro expansionparent_modulefrom_cŒcall_shortxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)inlined£urlHfile:///home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlpathA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlsource_packagecallxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)linfo_typeCore.MethodInstanceline,fileRecipesBase.jlfuncapply_recipeparent_modulefrom_cŒcall_short?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)inlined£urlLfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jlpathE/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jlsource_packagecall?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)linfo_typeCore.MethodInstanceline&fileuser_recipe.jlfunc_process_userrecipes!parent_modulefrom_cŒcall_short:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)inlined£urlPfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jlpathI/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jlsource_packagecall:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)linfo_typeCore.MethodInstancelineHfileRecipesPipeline.jlfuncrecipe_pipeline!parent_modulefrom_cŒcall_short7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)inlined£url;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jlpath4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jlsource_packagecall7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)linfo_typeCore.MethodInstancelineߤfileplot.jlfunc_plot!parent_modulefrom_cŒcall_short#plot!#197inlinedãurlpath4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jlsource_packagecall#plot!#197linfo_typeNothinglineդfileplot.jlfunc#plot!#197parent_modulefrom_cŒcall_shorttop-level scopeinlinedãurlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#9cd2bb00-04b1-11eb-1d83-a703907141a7source_packagecalltop-level scopelinfo_typeNothinglinefile.hw4.jl#==#9cd2bb00-04b1-11eb-1d83-a703907141a7func##function_wrapped_cell#406parent_modulefrom_c¤mime'application/vnd.pluto.stacktrace+objectrootassigneelast_run_timestampAڔpersist_js_state·has_pluto_hook_features§cell_id$9cd2bb00-04b1-11eb-1d83-a703907141a7depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bqueued¤logsrunning¦outputbodymsg2Cannot convert Missing to series data for plottingstacktracecall_shorterror(s::String)inlined£urlbhttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/error.jl#L33path./error.jlsource_packagecallerror(s::String)linfo_typeCore.MethodInstanceline!fileerror.jlfuncerrorparent_modulefrom_cŒcall_short _prepare_series_data(x::Missing)inlined£urlGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecall _prepare_series_data(x::Missing)linfo_typeCore.MethodInstancelinefileseries.jlfunc_prepare_series_dataparent_modulefrom_cŒcall_shortB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})inlined£urlGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecallB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})linfo_typeCore.MethodInstanceline$fileseries.jlfunc_series_data_vectorparent_modulefrom_cŒcall_shortmacro expansioninlinedãurlpath@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jlsource_packagecallmacro expansionlinfo_typeNothinglinéfileseries.jlfuncmacro expansionparent_modulefrom_cŒcall_shortxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)inlined£urlHfile:///home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlpathA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlsource_packagecallxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)linfo_typeCore.MethodInstanceline,fileRecipesBase.jlfuncapply_recipeparent_modulefrom_cŒcall_short?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)inlined£urlLfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jlpathE/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jlsource_packagecall?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)linfo_typeCore.MethodInstanceline&fileuser_recipe.jlfunc_process_userrecipes!parent_modulefrom_cŒcall_short:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)inlined£urlPfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jlpathI/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jlsource_packagecall:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)linfo_typeCore.MethodInstancelineHfileRecipesPipeline.jlfuncrecipe_pipeline!parent_modulefrom_cŒcall_short7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)inlined£url;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jlpath4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jlsource_packagecall7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)linfo_typeCore.MethodInstancelineߤfileplot.jlfunc_plot!parent_modulefrom_cŒcall_shortوplot(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})inlined£url;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jlpath4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jlsource_packagecallوplot(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})linfo_typeCore.MethodInstancelineffileplot.jlfunc#plot#186parent_modulefrom_cŒcall_short#bar#365inlinedãurlpathA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlsource_packagecall#bar#365linfo_typeNothinglinefileRecipesBase.jlfunc#bar#365parent_modulefrom_cŒcall_shortbarinlinedãurlpathA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jlsource_packagecallbarlinfo_typeNothinglinefileRecipesBase.jlfuncbarparent_modulefrom_cŒcall_shorttop-level scopeinlinedãurlpathd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bsource_packagecalltop-level scopelinfo_typeNothinglinefile.hw4.jl#==#8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bfunc##function_wrapped_cell#326parent_modulefrom_c¤mime'application/vnd.pluto.stacktrace+objectrootassigneelast_run_timestampA6&5persist_js_state·has_pluto_hook_features§cell_id$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$8631a536-0403-11eb-0379-bb2e56927727queued¤logsrunning¦outputbody

Exercise 2.3

👉 Write functions set_status!(a) and set_num_infected!(a) which modify the respective fields of an Agent. Check that they work. [Note the bang ("!") at the end of the function names to signify that these functions modify their argument.]

mimetext/htmlrootassigneelast_run_timestampAs^persist_js_state·has_pluto_hook_features§cell_id$8631a536-0403-11eb-0379-bb2e56927727depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$9a13b17c-0403-11eb-024f-9b37e95e211bqueued¤logsrunning¦outputbody

Exercise 4.2

👉 Run the simulation 20 times and plot $I$ as a function of time for each one, together with the mean over the 20 simulations (as you did in the previous exercises).

Note that you should be able to re-use the sweep! and simulation functions , since those should be sufficiently generic to work with the new step! function! (Modify them if they are not.)

mimetext/htmlrootassigneelast_run_timestampAw[persist_js_state·has_pluto_hook_features§cell_id$9a13b17c-0403-11eb-024f-9b37e95e211bdepends_on_disabled_cells§runtimeTȵpublished_object_keysdepends_on_skipped_cells§errored$b92f1cec-04ae-11eb-0072-3535d1118494queued¤logsrunning¦outputbodyelementsSmissingtext/plainImissingtext/plainRmissingtext/plaintypeNamedTupleobjectidffffffff7c5378c2mime!application/vnd.pluto.tree+objectrootassigneelast_run_timestampATpersist_js_state·has_pluto_hook_features§cell_id$b92f1cec-04ae-11eb-0072-3535d1118494depends_on_disabled_cells§runtime:ӵpublished_object_keysdepends_on_skipped_cells§errored$9a377b32-0403-11eb-2799-e7e59caa6a45queued¤logsrunning¦outputbody

👉 Run the new simulation and draw $I$ (averaged over runs) as a function of time. Is the behaviour qualitatively the same or different? Describe what you see.

mimetext/htmlrootassigneelast_run_timestampAw2Ypersist_js_state·has_pluto_hook_features§cell_id$9a377b32-0403-11eb-2799-e7e59caa6a45depends_on_disabled_cells§runtimeµpublished_object_keysdepends_on_skipped_cells§errored$778ec25c-0403-11eb-3146-1d11c294bb1fqueued¤logsrunning¦outputbodyٲ

Exercise 1.5

👉 What shape does the distribution seem to have? Can you verify that by adding a second plot with the expected shape?

mimetext/htmlrootassigneelast_run_timestampAqpersist_js_state·has_pluto_hook_features§cell_id$778ec25c-0403-11eb-3146-1d11c294bb1fdepends_on_disabled_cells§runtimevmpublished_object_keysdepends_on_skipped_cells§errored$9611ca24-0403-11eb-3582-b7e3bb243e62queued¤logsrunning¦outputbody

Exercise 3.3

👉 Plot the probability distribution of num_infected. Does it have a recognisable shape? (Feel free to increase the number of agents in order to get better statistics.)

mimetext/htmlrootassigneelast_run_timestampAvY>persist_js_state·has_pluto_hook_features§cell_id$9611ca24-0403-11eb-3582-b7e3bb243e62depends_on_disabled_cells§runtimeֽpublished_object_keysdepends_on_skipped_cells§errored$26f84600-041d-11eb-1856-b12a3e5c1dc7queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampArespersist_js_state·has_pluto_hook_features§cell_id$26f84600-041d-11eb-1856-b12a3e5c1dc7depends_on_disabled_cells§runtimeW8~published_object_keysdepends_on_skipped_cells§errored$1ca7a8c2-041a-11eb-146a-15b8cdeaea72queued¤logsrunning¦outputbodymissingmimetext/plainrootassigneelast_run_timestampAɾrpersist_js_state·has_pluto_hook_features§cell_id$1ca7a8c2-041a-11eb-146a-15b8cdeaea72depends_on_disabled_cells§runtime-3published_object_keysdepends_on_skipped_cells§errored$190deebc-0424-11eb-19fe-615997093e14queued¤logsrunning¦outputbody

👉 For convenience, define a new constructor (i.e. a new method for the function) that takes no arguments and creates an Agent with status S and number infected 0, by calling one of the default constructors that Julia creates. This new method lives outside (not inside) the definition of the struct. (It is called an outer constructor.)

(In Pluto, multiple methods for the same function need to be combined in a single cell using a begin end block.)

Let's check that the new method works correctly. How many methods does the constructor have now?

mimetext/htmlrootassigneelast_run_timestampAsCpersist_js_state·has_pluto_hook_features§cell_id$190deebc-0424-11eb-19fe-615997093e14depends_on_disabled_cells§runtime/published_object_keysdepends_on_skipped_cells§errored$1a654bdc-0421-11eb-2c38-7d35060e2565queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAʭذpersist_js_state·has_pluto_hook_features§cell_id$1a654bdc-0421-11eb-2c38-7d35060e2565depends_on_disabled_cells§runtime zJpublished_object_keysdepends_on_skipped_cells§errored$41cefa68-0414-11eb-3bad-6530360d6f68queued¤logsrunning¦outputbody.keep_working (generic function with 2 methods)mimetext/plainrootassigneelast_run_timestampA(ֶpersist_js_state·has_pluto_hook_features§cell_id$41cefa68-0414-11eb-3bad-6530360d6f68depends_on_disabled_cells§runtime gpublished_object_keysdepends_on_skipped_cells§errored$847d0fc2-041d-11eb-2864-79066e223b45queued¤logsrunning¦outputbody

👉 Convert x to an integer using the Integer function. What value does it have? What values do I and R have?

mimetext/htmlrootassigneelast_run_timestampArÏpersist_js_state·has_pluto_hook_features§cell_id$847d0fc2-041d-11eb-2864-79066e223b45depends_on_disabled_cells§runtimeNҵpublished_object_keysdepends_on_skipped_cells§errored$77428072-0403-11eb-0068-81e3728f2ebequeued¤logsrunning¦outputbodyٗ

Let's run an experiment with $p=0.25$ and $N=10,000$.

mimetext/htmlrootassigneelast_run_timestampAqpersist_js_state·has_pluto_hook_features§cell_id$77428072-0403-11eb-0068-81e3728f2ebedepends_on_disabled_cells§runtime ѵpublished_object_keysdepends_on_skipped_cells§errored$9a837b52-0425-11eb-231f-a74405ff6e23queued¤logsrunning¦outputbody/is_susceptible (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAʖ13persist_js_state·has_pluto_hook_features§cell_id$9a837b52-0425-11eb-231f-a74405ff6e23depends_on_disabled_cells§runtimejlpublished_object_keysdepends_on_skipped_cells§errored$0a967f38-0493-11eb-0624-77e40b24d757queued¤logsrunning¦outputbody

We used a let block in this cell to group multiple expressions together, but how is it different from begin or function?

function vs. begin vs. let

Writing functions is a way to group multiple expressions (i.e. lines of code) together into a mini-program. Note the following about functions:

  • A function always returns one object.[1] This object can be given explicitly by writing return x, or implicitly: Julia functions always return the result of the last expression by default. So f(x) = x+2 is the same as f(x) = return x+2.

  • Variables defined inside a function are not accessible outside the function. We say that function bodies have a local scope. This helps to keep your program easy to read and write: if you define a local variable, then you don't need to worry about it in the rest of the notebook.

There are two other ways to group epxressions together that you might have seen before: begin and let.

begin

begin will group expressions together, and it takes the value of its last subexpression.

We use it in this notebook when we want multiple expressions to always run together.

let

let also groups multiple expressions together into one, but variables defined inside of it are local: they don't affect code outside of the block. So like begin, it is just a block of code, but like function, it has a local variable scope.

We use it when we want to define some local (temporary) variables to produce a complicated result, without interfering with other cells. Pluto allows only one definition per global variable of the same name, but you can define local variables with the same names whenever you wish!

1

Even a function like

f(x) = return

returns one object: the object nothing — try it out!

mimetext/htmlrootassigneelast_run_timestampAupersist_js_state·has_pluto_hook_features§cell_id$0a967f38-0493-11eb-0624-77e40b24d757depends_on_disabled_cells§runtime tpublished_object_keysdepends_on_skipped_cells§errored$28db9d98-04ca-11eb-3606-9fb89fa62f36queued¤logsrunning¦outputbodymmimetext/htmlrootassigneelast_run_timestampA)persist_js_state·has_pluto_hook_features§cell_id$28db9d98-04ca-11eb-3606-9fb89fa62f36depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$8692bf42-0403-11eb-191f-b7d08895274fqueued¤logsrunning¦outputbody8

Exericse 2.4

👉 Write a function generate_agents(N) that returns a vector of N freshly created Agents. They should all be initially susceptible, except one, chosen at random (i.e. uniformly), who is infectious.

mimetext/htmlrootassigneelast_run_timestampAspersist_js_state·has_pluto_hook_features§cell_id$8692bf42-0403-11eb-191f-b7d08895274fdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$da49710e-0420-11eb-092e-4f1173868738queued¤logsrunning¦outputbody

Exercise 5 - Lecture transcript

(MIT students only) Please see the link for hw 4 transcript document on Canvas. We want each of you to correct about 400 lines, but don’t spend more than 15 minutes on it. See the the beginning of the document for more instructions. :point_right: Please mention the name of the video(s) and the line ranges you edited:

mimetext/htmlrootassigneelast_run_timestampAwapersist_js_state·has_pluto_hook_features§cell_id$da49710e-0420-11eb-092e-4f1173868738depends_on_disabled_cells§runtimetpublished_object_keysdepends_on_skipped_cells§errored$7bb8e426-0495-11eb-3a8b-cbbab61a1631queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAr,persist_js_state·has_pluto_hook_features§cell_id$7bb8e426-0495-11eb-3a8b-cbbab61a1631depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$21c50840-0435-11eb-1307-7138ecde0691queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAwEApersist_js_state·has_pluto_hook_features§cell_id$21c50840-0435-11eb-1307-7138ecde0691depends_on_disabled_cells§runtimeKpublished_object_keysdepends_on_skipped_cells§errored$2ade2694-0425-11eb-2fb2-390da43d9695queued¤logsrunning¦outputbody&step! (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAA)persist_js_state·has_pluto_hook_features§cell_id$2ade2694-0425-11eb-2fb2-390da43d9695depends_on_disabled_cells§runtime؎published_object_keysdepends_on_skipped_cells§errored$bf6fd176-04cc-11eb-008a-2fb6ff70a9cbqueued¤logsrunning¦outputbody

Exercise 3.2

Alright! Every time that we run the simulation, we get slightly different results, because it is based on randomness. By running the simulation a number of times, you start to get an idea of the mean behaviour of our model. This is the essence of a Monte Carlo method! You use computer-generated randomness to generate samples.

Instead of pressing the button many times, let's have the computer repeat the simulation. In the next cells, we run your simulation num_simulations=20 times with $N=100$, $p_\text{infection} = 0.02$, $p_\text{infection} = 0.002$ and $T = 1000$.

Every single simulation returns a named tuple with the status counts, so the result of multiple simulations will be an array of those. Have a look inside the result, simulations, and make sure that its structure is clear.

mimetext/htmlrootassigneelast_run_timestampAuƂpersist_js_state·has_pluto_hook_features§cell_id$bf6fd176-04cc-11eb-008a-2fb6ff70a9cbdepends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$73047bba-0416-11eb-1047-23e9c3dbde05queued¤logsrunning¦outputbody-

blablabla

mimetext/htmlrootassigneeinterpretation_of_p_equals_onelast_run_timestampAɓfpersist_js_state·has_pluto_hook_features§cell_id$73047bba-0416-11eb-1047-23e9c3dbde05depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$43e6e856-0414-11eb-19ca-07358aa8b667queued¤logsrunning¦outputbody/still_missing (generic function with 2 methods)mimetext/plainrootassigneelast_run_timestampA冰persist_js_state·has_pluto_hook_features§cell_id$43e6e856-0414-11eb-19ca-07358aa8b667depends_on_disabled_cells§runtime published_object_keysdepends_on_skipped_cells§errored$2b26dc42-0403-11eb-205f-cd2c23d8cb03queued¤logsrunning¦outputbody




mimetext/htmlrootassigneelast_run_timestampAwJpersist_js_state·has_pluto_hook_features§cell_id$2b26dc42-0403-11eb-205f-cd2c23d8cb03depends_on_disabled_cells§runtime%published_object_keysdepends_on_skipped_cells§errored$95c598d4-0403-11eb-2328-0175ed564915queued¤logsrunning¦outputbody

👉 Write a function sir_mean_plot that returns a plot of the means of $S$, $I$ and $R$ as a function of time on a single graph.

mimetext/htmlrootassigneelast_run_timestampAu˰persist_js_state·has_pluto_hook_features§cell_id$95c598d4-0403-11eb-2328-0175ed564915depends_on_disabled_cells§runtime}published_object_keysdepends_on_skipped_cells§errored$1ac4b33a-0435-11eb-36f8-8f3f81ae7844queued¤logsrunning¦outputbodymimetext/plainrootassigneelast_run_timestampAwpersist_js_state·has_pluto_hook_features§cell_id$1ac4b33a-0435-11eb-36f8-8f3f81ae7844depends_on_disabled_cells§runtimepublished_object_keysdepends_on_skipped_cells§errored$a8dd5cae-0425-11eb-119c-bfcbf832d695queued¤logsrunning¦outputbody,is_infected (generic function with 1 method)mimetext/plainrootassigneelast_run_timestampAʠepersist_js_state·has_pluto_hook_features§cell_id$a8dd5cae-0425-11eb-119c-bfcbf832d695depends_on_disabled_cells§runtimexypublished_object_keysdepends_on_skipped_cells§errored±cell_dependencies$f1f89502-0494-11eb-2303-0b79d8bbd13fprecedence_heuristic cell_id$f1f89502-0494-11eb-2303-0b79d8bbd13fdownstream_cells_mapfrequencies_plot_with_mean$06089d1e-0495-11eb-0ace-a7a7dc60e5b2upstream_cells_mapmissing$95771ce2-0403-11eb-3056-f1dc3a8b7ec3precedence_heuristic cell_id$95771ce2-0403-11eb-3056-f1dc3a8b7ec3downstream_cells_mapupstream_cells_map@md_strgetindex$e6219c7c-0420-11eb-3faa-13126f7c8007precedence_heuristic cell_id$e6219c7c-0420-11eb-3faa-13126f7c8007downstream_cells_maplines_i_editedupstream_cells_map@md_strgetindex$b817f466-04d4-11eb-0a26-c1c667f9f7f7precedence_heuristic cell_id$b817f466-04d4-11eb-0a26-c1c667f9f7f7downstream_cells_mapupstream_cells_map@md_strBase.getindexMissing!@isdefinedBoolstill_missing$43e6e856-0414-11eb-19ca-07358aa8b667isaBasecorrect$3d88c056-0414-11eb-0025-05d3aff1588bkeep_working$41cefa68-0414-11eb-3bad-6530360d6f68not_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73d==bernoulli$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9$08e2bc64-0417-11eb-1457-21c0d18e8c51precedence_heuristic cell_id$08e2bc64-0417-11eb-1457-21c0d18e8c51downstream_cells_mapupstream_cells_map@md_strhint$48a16c42-0414-11eb-0e0c-bf52bbb0f618getindex$bb8aeb58-042f-11eb-18b8-f995631df619precedence_heuristic cell_id$bb8aeb58-042f-11eb-18b8-f995631df619downstream_cells_mapupstream_cells_map@md_strgetindex$223933a4-042c-11eb-10d3-852229f25a35precedence_heuristic cell_id$223933a4-042c-11eb-10d3-852229f25a35downstream_cells_mapAbstractInfection$1a654bdc-0421-11eb-2c38-7d35060e2565$2ade2694-0425-11eb-2fb2-390da43d9695$46133a74-04b1-11eb-0b46-0bc74e564680$887d27fc-04bc-11eb-0ab9-eb95ef9607f8upstream_cells_map$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2precedence_heuristic cell_id$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2downstream_cells_mapAgent$82f2580a-04c8-11eb-1eea-bdb4e50eee3b$98beb336-0425-11eb-3886-4f8cfd210288$7c515a7a-04d5-11eb-0f36-4fcebff709d5$9a837b52-0425-11eb-231f-a74405ff6e23$a8dd5cae-0425-11eb-119c-bfcbf832d695$c4a8694a-04d4-11eb-1eef-c9e037e6b21f$393041ec-049f-11eb-3089-2faf378445f3$406aabea-04a5-11eb-06b8-312879457c42$9c39974c-04a5-11eb-184d-317eb542452c$759bc42e-04ab-11eb-0ab1-b12e008c02a9$1491a078-04aa-11eb-0106-19a3cf1e94b0$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272$2ade2694-0425-11eb-2fb2-390da43d9695$46133a74-04b1-11eb-0b46-0bc74e564680upstream_cells_mapInt64InfectionStatus$26f84600-041d-11eb-1856-b12a3e5c1dc7$7f635722-04d0-11eb-3209-4b603c9e843cprecedence_heuristic cell_id$7f635722-04d0-11eb-3209-4b603c9e843cdownstream_cells_mapupstream_cells_mapsimulations$80c2cd88-04b1-11eb-326e-0120a39405easir_mean_plot$843fd63c-04d0-11eb-0113-c58d346179d6$7c515a7a-04d5-11eb-0f36-4fcebff709d5precedence_heuristic cell_id$7c515a7a-04d5-11eb-0f36-4fcebff709d5downstream_cells_mapupstream_cells_mapI$26f84600-041d-11eb-1856-b12a3e5c1dc7correct$3d88c056-0414-11eb-0025-05d3aff1588bkeep_working$41cefa68-0414-11eb-3bad-6530360d6f68!not_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73d@isdefinedAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2R$26f84600-041d-11eb-1856-b12a3e5c1dc7==set_status!$98beb336-0425-11eb-3886-4f8cfd210288$107e65a4-0403-11eb-0c14-37d8d828b469precedence_heuristic cell_id$107e65a4-0403-11eb-0c14-37d8d828b469downstream_cells_mapupstream_cells_map@md_strgetindex$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0precedence_heuristic cell_id$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0downstream_cells_mapupstream_cells_map$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bbprecedence_heuristic cell_id$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bbdownstream_cells_mapupstream_cells_map@md_strgetindex$7f4e121c-041d-11eb-0dff-cd0cbfdfd606precedence_heuristic cell_id$7f4e121c-041d-11eb-0dff-cd0cbfdfd606downstream_cells_maptest_statusupstream_cells_mapmissing$4f19e872-0414-11eb-0dfd-e53d2aecc4dcprecedence_heuristic cell_id$4f19e872-0414-11eb-0dfd-e53d2aecc4dcdownstream_cells_mapupstream_cells_map@md_strgetindex$5689841e-0414-11eb-0492-63c77ddbd136precedence_heuristic cell_id$5689841e-0414-11eb-0492-63c77ddbd136downstream_cells_mapupstream_cells_mapbigbreak$39dffa3c-0414-11eb-0197-e72b299e9c63$759bc42e-04ab-11eb-0ab1-b12e008c02a9precedence_heuristic cell_id$759bc42e-04ab-11eb-0ab1-b12e008c02a9downstream_cells_mapupstream_cells_map@md_strBase.getindex!@isdefinedAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2interact!$406aabea-04a5-11eb-06b8-312879457c42BaseI$26f84600-041d-11eb-1856-b12a3e5c1dc7S$26f84600-041d-11eb-1856-b12a3e5c1dc7correct$3d88c056-0414-11eb-0025-05d3aff1588bkeep_working$41cefa68-0414-11eb-3bad-6530360d6f68not_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73d!=R$26f84600-041d-11eb-1856-b12a3e5c1dc7==almost$461586dc-0414-11eb-00f3-4984b57bfac5InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$99ef7b2a-0403-11eb-08ef-e1023cd151aeprecedence_heuristic cell_id$99ef7b2a-0403-11eb-08ef-e1023cd151aedownstream_cells_mapupstream_cells_map@md_strgetindex$77b54c10-0403-11eb-16ad-65374d29a817precedence_heuristic cell_id$77b54c10-0403-11eb-16ad-65374d29a817downstream_cells_mapupstream_cells_map@md_strgetindex$7768a2dc-0403-11eb-39b7-fd660dc952feprecedence_heuristic cell_id$7768a2dc-0403-11eb-39b7-fd660dc952fedownstream_cells_mapupstream_cells_map@md_strgetindex$60a8b708-04c8-11eb-37b1-3daec644ac90precedence_heuristic cell_id$60a8b708-04c8-11eb-37b1-3daec644ac90downstream_cells_mapupstream_cells_map$95eb9f88-0403-11eb-155b-7b2d3a07cff0precedence_heuristic cell_id$95eb9f88-0403-11eb-155b-7b2d3a07cff0downstream_cells_mapupstream_cells_map@md_strgetindex$955321de-0403-11eb-04ce-fb1670dfbb9eprecedence_heuristic cell_id$955321de-0403-11eb-04ce-fb1670dfbb9edownstream_cells_mapupstream_cells_map@md_strgetindex$ae70625a-041f-11eb-3082-0753419d6d57precedence_heuristic cell_id$ae70625a-041f-11eb-3082-0753419d6d57downstream_cells_mapupstream_cells_map@md_strgetindex$843fd63c-04d0-11eb-0113-c58d346179d6precedence_heuristic cell_id$843fd63c-04d0-11eb-0113-c58d346179d6downstream_cells_mapsir_mean_plot$7f635722-04d0-11eb-3209-4b603c9e843cupstream_cells_mapNamedTuplelengthmissingfirstVector$189cae1e-0424-11eb-2666-65bf297d8bddprecedence_heuristic cell_id$189cae1e-0424-11eb-2666-65bf297d8bdddownstream_cells_mapupstream_cells_map@md_strgetindex$7f744644-041d-11eb-08a0-3719cc0adeb7precedence_heuristic cell_id$7f744644-041d-11eb-08a0-3719cc0adeb7downstream_cells_mapupstream_cells_map@md_strgetindex$488771e2-049f-11eb-3b0a-0de260457731precedence_heuristic cell_id$488771e2-049f-11eb-3b0a-0de260457731downstream_cells_mapupstream_cells_mapgenerate_agents$7946d83a-04a0-11eb-224b-2b315e87bc84$393041ec-049f-11eb-3089-2faf378445f3precedence_heuristic cell_id$393041ec-049f-11eb-3089-2faf378445f3downstream_cells_mapupstream_cells_map@md_strsumMissing!Vectorlengthcorrect$3d88c056-0414-11eb-0025-05d3aff1588bkeep_working$41cefa68-0414-11eb-3bad-6530360d6f68not_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73d!===almost$461586dc-0414-11eb-00f3-4984b57bfac5SetBase.getindexNothing@isdefinedAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2still_missing$43e6e856-0414-11eb-19ca-07358aa8b667generate_agents$7946d83a-04a0-11eb-224b-2b315e87bc84isaBaseallI$26f84600-041d-11eb-1856-b12a3e5c1dc7$531d13c2-0414-11eb-0acd-4905a684869dprecedence_heuristic cell_id$531d13c2-0414-11eb-0acd-4905a684869ddownstream_cells_mapupstream_cells_map@md_strstudent$095cbf46-0403-11eb-0c37-35de9562cebc==getindex$06f30b2a-0403-11eb-0f05-8badebe1011dprecedence_heuristic cell_id$06f30b2a-0403-11eb-0f05-8badebe1011ddownstream_cells_mapupstream_cells_map@md_strgetindex$9c39974c-04a5-11eb-184d-317eb542452cprecedence_heuristic cell_id$9c39974c-04a5-11eb-184d-317eb542452cdownstream_cells_mapupstream_cells_mapInfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565I$26f84600-041d-11eb-1856-b12a3e5c1dc7S$26f84600-041d-11eb-1856-b12a3e5c1dc7Agent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2interact!$406aabea-04a5-11eb-06b8-312879457c42$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1precedence_heuristic cell_id$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1downstream_cells_mapupstream_cells_maplarge_experiment$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8frequencies_plot_with_maximum$823364ce-041c-11eb-2467-7ffa4f751527$06089d1e-0495-11eb-0ace-a7a7dc60e5b2precedence_heuristic cell_id$06089d1e-0495-11eb-0ace-a7a7dc60e5b2downstream_cells_mapupstream_cells_maplarge_experiment$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8frequencies_plot_with_mean$f1f89502-0494-11eb-2303-0b79d8bbd13f$15187690-0403-11eb-2dfd-fd924faa3513precedence_heuristiccell_id$15187690-0403-11eb-2dfd-fd924faa3513downstream_cells_mapPlutoUIPlotsupstream_cells_mapPkg.addPkg$12cc2940-0403-11eb-19a7-bb570de58f6fplotly$d8abd2f6-0416-11eb-1c2a-f9157d9760a7precedence_heuristic cell_id$d8abd2f6-0416-11eb-1c2a-f9157d9760a7downstream_cells_mapsmall_experiment$1ca7a8c2-041a-11eb-146a-15b8cdeaea72upstream_cells_mapdo_experiment$c5c7cb86-041b-11eb-3360-45463105f3c9$9374e63c-0493-11eb-0952-4b97512d7cdbprecedence_heuristic cell_id$9374e63c-0493-11eb-0952-4b97512d7cdbdownstream_cells_mapupstream_cells_map@md_strgetindex$2d3bba2a-04a8-11eb-2c40-87794b6aeeacprecedence_heuristic cell_id$2d3bba2a-04a8-11eb-2c40-87794b6aeeacdownstream_cells_mapupstream_cells_map@md_strBase.getindexBaseBase.Docs.HTML@html_str$dfb99ace-04cf-11eb-0739-7d694c837d59precedence_heuristic cell_id$dfb99ace-04cf-11eb-0739-7d694c837d59downstream_cells_mapupstream_cells_map@md_strgetindex$271ec5f0-041d-11eb-041b-db46ec1465e0precedence_heuristic cell_id$271ec5f0-041d-11eb-041b-db46ec1465e0downstream_cells_mapupstream_cells_map@md_strgetindex$7946d83a-04a0-11eb-224b-2b315e87bc84precedence_heuristic cell_id$7946d83a-04a0-11eb-224b-2b315e87bc84downstream_cells_mapgenerate_agents$488771e2-049f-11eb-3b0a-0de260457731$393041ec-049f-11eb-3089-2faf378445f3upstream_cells_mapmissingInteger$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9precedence_heuristic cell_id$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9downstream_cells_mapbernoulli$b817f466-04d4-11eb-0a26-c1c667f9f7f7upstream_cells_mapmissingNumber$9635c944-0403-11eb-3982-4df509f6a556precedence_heuristic cell_id$9635c944-0403-11eb-3982-4df509f6a556downstream_cells_mapupstream_cells_map@md_strgetindex$f3f81172-041c-11eb-2b9b-e99b7b9400edprecedence_heuristic cell_id$f3f81172-041c-11eb-2b9b-e99b7b9400eddownstream_cells_mapupstream_cells_map@md_strBase.getindexBaseBase.Docs.HTML@html_str$4ad11052-042c-11eb-3643-8b2b3e1269bcprecedence_heuristic cell_id$4ad11052-042c-11eb-3643-8b2b3e1269bcdownstream_cells_mapupstream_cells_map$76d117d4-0403-11eb-05d2-c5ea47d06f43precedence_heuristic cell_id$76d117d4-0403-11eb-05d2-c5ea47d06f43downstream_cells_mapupstream_cells_map@md_strgetindex$095cbf46-0403-11eb-0c37-35de9562cebcprecedence_heuristic cell_id$095cbf46-0403-11eb-0c37-35de9562cebcdownstream_cells_mapstudent$03a85970-0403-11eb-334a-812b59c0905b$531d13c2-0414-11eb-0acd-4905a684869dupstream_cells_map$26e2978e-0435-11eb-0d61-25f552d2771eprecedence_heuristic cell_id$26e2978e-0435-11eb-0d61-25f552d2771edownstream_cells_mapupstream_cells_map$6de37d6c-0415-11eb-1b05-85ac820016c7precedence_heuristic cell_id$6de37d6c-0415-11eb-1b05-85ac820016c7downstream_cells_mapupstream_cells_map@md_strgetindex$18d308c4-0424-11eb-176d-49feec6889cfprecedence_heuristic cell_id$18d308c4-0424-11eb-176d-49feec6889cfdownstream_cells_maptest_agentupstream_cells_mapmissing$46133a74-04b1-11eb-0b46-0bc74e564680precedence_heuristic cell_id$46133a74-04b1-11eb-0b46-0bc74e564680downstream_cells_mapsweep!upstream_cells_mapAbstractInfection$223933a4-042c-11eb-10d3-852229f25a35Agent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Vector$771c8f0c-0403-11eb-097e-ab24d0714ad5precedence_heuristic cell_id$771c8f0c-0403-11eb-097e-ab24d0714ad5downstream_cells_mapupstream_cells_map@md_strgetindex$80c2cd88-04b1-11eb-326e-0120a39405eaprecedence_heuristic cell_id$80c2cd88-04b1-11eb-326e-0120a39405eadownstream_cells_mapsimulations$9cd2bb00-04b1-11eb-1d83-a703907141a7$7f635722-04d0-11eb-3209-4b603c9e843cupstream_cells_maprepeat_simulations$38b1aa5a-04cf-11eb-11a2-930741fc9076InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$105d347e-041c-11eb-2fc8-1d9e5eda2be0precedence_heuristic cell_id$105d347e-041c-11eb-2fc8-1d9e5eda2be0downstream_cells_mapfrequencies$1ca7a8c2-041a-11eb-146a-15b8cdeaea72$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b$823364ce-041c-11eb-2467-7ffa4f751527upstream_cells_mapmissing$2c62b4ae-04b3-11eb-0080-a1035a7e31a2precedence_heuristic cell_id$2c62b4ae-04b3-11eb-0080-a1035a7e31a2downstream_cells_mapupstream_cells_mapsimulation$887d27fc-04bc-11eb-0ab9-eb95ef9607f8InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$6db6c894-0415-11eb-305a-c75b119d89e9precedence_heuristic cell_id$6db6c894-0415-11eb-305a-c75b119d89e9downstream_cells_mapupstream_cells_map@md_strgetindex$77db111e-0403-11eb-2dea-4b42ceed65d6precedence_heuristic cell_id$77db111e-0403-11eb-2dea-4b42ceed65d6downstream_cells_mapupstream_cells_map@md_strgetindex$3d88c056-0414-11eb-0025-05d3aff1588bprecedence_heuristic cell_id$3d88c056-0414-11eb-0025-05d3aff1588bdownstream_cells_mapcorrect$b817f466-04d4-11eb-0a26-c1c667f9f7f7$c61f35ea-04d6-11eb-2503-17a79f8d0298$7c515a7a-04d5-11eb-0f36-4fcebff709d5$c4a8694a-04d4-11eb-1eef-c9e037e6b21f$393041ec-049f-11eb-3089-2faf378445f3$759bc42e-04ab-11eb-0ab1-b12e008c02a9$1491a078-04aa-11eb-0106-19a3cf1e94b0$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272upstream_cells_mapMarkdown.Admonitionyays$3f5e0af8-0414-11eb-34a7-a71e7aaf6443Markdown.MDMarkdownrand$287ee7aa-0435-11eb-0ca3-951dbbe69404precedence_heuristic cell_id$287ee7aa-0435-11eb-0ca3-951dbbe69404downstream_cells_mapsir_mean_error_plotupstream_cells_mapNamedTuplelengthmissingfirstVector$03a85970-0403-11eb-334a-812b59c0905bprecedence_heuristic cell_id$03a85970-0403-11eb-334a-812b59c0905bdownstream_cells_mapupstream_cells_map@md_strstudent$095cbf46-0403-11eb-0c37-35de9562cebcgetindex$6d906d0c-0415-11eb-0c1c-b5c0aca841dbprecedence_heuristic cell_id$6d906d0c-0415-11eb-0c1c-b5c0aca841dbdownstream_cells_mapupstream_cells_map@md_strhint$48a16c42-0414-11eb-0e0c-bf52bbb0f618getindex$866299e8-0403-11eb-085d-2b93459cc141precedence_heuristic cell_id$866299e8-0403-11eb-085d-2b93459cc141downstream_cells_mapupstream_cells_map@md_strgetindex$461586dc-0414-11eb-00f3-4984b57bfac5precedence_heuristic cell_id$461586dc-0414-11eb-00f3-4984b57bfac5downstream_cells_mapalmost$393041ec-049f-11eb-3089-2faf378445f3$759bc42e-04ab-11eb-0ab1-b12e008c02a9upstream_cells_mapMarkdown.AdmonitionMarkdown.MDMarkdown$c5156c72-04af-11eb-1106-b13969b036caprecedence_heuristic cell_id$c5156c72-04af-11eb-1106-b13969b036cadownstream_cells_mapupstream_cells_map:plotrun_basic_sir$28db9d98-04ca-11eb-3606-9fb89fa62f36simulation$887d27fc-04bc-11eb-0ab9-eb95ef9607f8plot!InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$c4a8694a-04d4-11eb-1eef-c9e037e6b21fprecedence_heuristic cell_id$c4a8694a-04d4-11eb-1eef-c9e037e6b21fdownstream_cells_mapupstream_cells_map@md_strBase.getindexMissing!is_susceptible$9a837b52-0425-11eb-231f-a74405ff6e23@isdefinedBoolAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2still_missing$43e6e856-0414-11eb-19ca-07358aa8b667is_infected$a8dd5cae-0425-11eb-119c-bfcbf832d695isaI$26f84600-041d-11eb-1856-b12a3e5c1dc7S$26f84600-041d-11eb-1856-b12a3e5c1dc7===keep_working$41cefa68-0414-11eb-3bad-6530360d6f68Basenot_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73dcorrect$3d88c056-0414-11eb-0025-05d3aff1588bR$26f84600-041d-11eb-1856-b12a3e5c1dc7$1491a078-04aa-11eb-0106-19a3cf1e94b0precedence_heuristic cell_id$1491a078-04aa-11eb-0106-19a3cf1e94b0downstream_cells_mapupstream_cells_map@md_strBase.getindex!@isdefinedAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2interact!$406aabea-04a5-11eb-06b8-312879457c42BaseI$26f84600-041d-11eb-1856-b12a3e5c1dc7S$26f84600-041d-11eb-1856-b12a3e5c1dc7correct$3d88c056-0414-11eb-0025-05d3aff1588bkeep_working$41cefa68-0414-11eb-3bad-6530360d6f68not_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73d!=R$26f84600-041d-11eb-1856-b12a3e5c1dc7==InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$c5c7cb86-041b-11eb-3360-45463105f3c9precedence_heuristic cell_id$c5c7cb86-041b-11eb-3360-45463105f3c9downstream_cells_mapdo_experiment$d8abd2f6-0416-11eb-1c2a-f9157d9760a7$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8upstream_cells_mapmissing$01341648-0403-11eb-2212-db450c299f35precedence_heuristic cell_id$01341648-0403-11eb-2212-db450c299f35downstream_cells_mapupstream_cells_map@md_strgetindex$48a16c42-0414-11eb-0e0c-bf52bbb0f618precedence_heuristic cell_id$48a16c42-0414-11eb-0e0c-bf52bbb0f618downstream_cells_maphint$6d906d0c-0415-11eb-0c1c-b5c0aca841db$08e2bc64-0417-11eb-1457-21c0d18e8c51$9cf9080a-04b1-11eb-12a0-17013f2d37f5upstream_cells_mapMarkdown.AdmonitionMarkdown.MDMarkdown$98beb336-0425-11eb-3886-4f8cfd210288precedence_heuristic cell_id$98beb336-0425-11eb-3886-4f8cfd210288downstream_cells_mapset_status!$7c515a7a-04d5-11eb-0f36-4fcebff709d5upstream_cells_mapInfectionStatus$26f84600-041d-11eb-1856-b12a3e5c1dc7Agent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2$bb63f3cc-042f-11eb-04ff-a128aec3c378precedence_heuristic cell_id$bb63f3cc-042f-11eb-04ff-a128aec3c378downstream_cells_mapupstream_cells_map$61c00724-0403-11eb-228d-17c11670e5d1precedence_heuristic cell_id$61c00724-0403-11eb-228d-17c11670e5d1downstream_cells_mapupstream_cells_map@md_strgetindex$9cf9080a-04b1-11eb-12a0-17013f2d37f5precedence_heuristic cell_id$9cf9080a-04b1-11eb-12a0-17013f2d37f5downstream_cells_mapupstream_cells_map@md_strhint$48a16c42-0414-11eb-0e0c-bf52bbb0f618getindex$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8precedence_heuristic cell_id$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8downstream_cells_maplarge_experiment$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1$06089d1e-0495-11eb-0ace-a7a7dc60e5b2upstream_cells_mapdo_experiment$c5c7cb86-041b-11eb-3360-45463105f3c9$61789646-0403-11eb-0042-f3b8308f11baprecedence_heuristic cell_id$61789646-0403-11eb-0042-f3b8308f11badownstream_cells_mapupstream_cells_map@md_strgetindex$39dffa3c-0414-11eb-0197-e72b299e9c63precedence_heuristic cell_id$39dffa3c-0414-11eb-0197-e72b299e9c63downstream_cells_mapbigbreak$2b26dc42-0403-11eb-205f-cd2c23d8cb03$5689841e-0414-11eb-0492-63c77ddbd136upstream_cells_mapBaseBase.Docs.HTML@html_str$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272precedence_heuristic cell_id$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272downstream_cells_mapupstream_cells_map@md_strBase.getindex!@isdefinedAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2interact!$406aabea-04a5-11eb-06b8-312879457c42BaseI$26f84600-041d-11eb-1856-b12a3e5c1dc7correct$3d88c056-0414-11eb-0025-05d3aff1588bkeep_working$41cefa68-0414-11eb-3bad-6530360d6f68not_defined$3c0528a0-0414-11eb-2f68-a5657ab9e73d!=R$26f84600-041d-11eb-1856-b12a3e5c1dc7==InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$88c53208-041d-11eb-3b1e-31b57ba99f05precedence_heuristic cell_id$88c53208-041d-11eb-3b1e-31b57ba99f05downstream_cells_mapupstream_cells_map$887d27fc-04bc-11eb-0ab9-eb95ef9607f8precedence_heuristic cell_id$887d27fc-04bc-11eb-0ab9-eb95ef9607f8downstream_cells_mapsimulation$b92f1cec-04ae-11eb-0072-3535d1118494$2c62b4ae-04b3-11eb-0080-a1035a7e31a2$c5156c72-04af-11eb-1106-b13969b036ca$38b1aa5a-04cf-11eb-11a2-930741fc9076upstream_cells_mapmissingAbstractInfection$223933a4-042c-11eb-10d3-852229f25a35Integer$d57c6a5a-041b-11eb-3ab4-774a2d45a891precedence_heuristic cell_id$d57c6a5a-041b-11eb-3ab4-774a2d45a891downstream_cells_maprecovery_time$c61f35ea-04d6-11eb-2503-17a79f8d0298upstream_cells_map<=missingthrow≤ArgumentError$12cc2940-0403-11eb-19a7-bb570de58f6fprecedence_heuristiccell_id$12cc2940-0403-11eb-19a7-bb570de58f6fdownstream_cells_mapPkg$12cc2940-0403-11eb-19a7-bb570de58f6f$15187690-0403-11eb-2dfd-fd924faa3513upstream_cells_mapPkg$12cc2940-0403-11eb-19a7-bb570de58f6fPkg.activatemktempdir$76f62d64-0403-11eb-27e2-3de58366b619precedence_heuristic cell_id$76f62d64-0403-11eb-27e2-3de58366b619downstream_cells_mapupstream_cells_map@md_strgetindex$860790fc-0403-11eb-2f2e-355f77dcc7afprecedence_heuristic cell_id$860790fc-0403-11eb-2f2e-355f77dcc7afdownstream_cells_mapupstream_cells_map@md_strgetindex$b21475c6-04ac-11eb-1366-f3b5e967402dprecedence_heuristic cell_id$b21475c6-04ac-11eb-1366-f3b5e967402ddownstream_cells_mapupstream_cells_map@md_strgetindex$823364ce-041c-11eb-2467-7ffa4f751527precedence_heuristic cell_id$823364ce-041c-11eb-2467-7ffa4f751527downstream_cells_mapfrequencies_plot_with_maximum$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1upstream_cells_mapbarvline!frequencies$105d347e-041c-11eb-2fc8-1d9e5eda2be0maximumVector$619c8a10-0403-11eb-2e89-8b0974fb01d0precedence_heuristic cell_id$619c8a10-0403-11eb-2e89-8b0974fb01d0downstream_cells_mapupstream_cells_map@md_strgetindex$38b1aa5a-04cf-11eb-11a2-930741fc9076precedence_heuristic cell_id$38b1aa5a-04cf-11eb-11a2-930741fc9076downstream_cells_maprepeat_simulations$80c2cd88-04b1-11eb-326e-0120a39405eaupstream_cells_map:mapsimulation$887d27fc-04bc-11eb-0ab9-eb95ef9607f8$8dd97820-04a5-11eb-36c0-8f92d4b859a8precedence_heuristic cell_id$8dd97820-04a5-11eb-36c0-8f92d4b859a8downstream_cells_mapupstream_cells_map$df8547b4-0400-11eb-07c6-fb370b61c2b6precedence_heuristic cell_id$df8547b4-0400-11eb-07c6-fb370b61c2b6downstream_cells_mapupstream_cells_map@md_strgetindex$1d3356c4-0403-11eb-0f48-01b5eb14a585precedence_heuristic cell_id$1d3356c4-0403-11eb-0f48-01b5eb14a585downstream_cells_mapupstream_cells_mapBaseBase.Docs.HTML@html_str$82f2580a-04c8-11eb-1eea-bdb4e50eee3bprecedence_heuristic cell_id$82f2580a-04c8-11eb-1eea-bdb4e50eee3bdownstream_cells_mapupstream_cells_mapAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2$86d98d0a-0403-11eb-215b-c58ad721a90bprecedence_heuristic cell_id$86d98d0a-0403-11eb-215b-c58ad721a90bdownstream_cells_mapupstream_cells_map@md_strgetindex$dc784864-0430-11eb-1478-d1153e017310precedence_heuristic cell_id$dc784864-0430-11eb-1478-d1153e017310downstream_cells_mapupstream_cells_map@md_strgetindex$3f5e0af8-0414-11eb-34a7-a71e7aaf6443precedence_heuristic cell_id$3f5e0af8-0414-11eb-34a7-a71e7aaf6443downstream_cells_mapyays$3d88c056-0414-11eb-0025-05d3aff1588bupstream_cells_map@md_strgetindex$3c0528a0-0414-11eb-2f68-a5657ab9e73dprecedence_heuristic cell_id$3c0528a0-0414-11eb-2f68-a5657ab9e73ddownstream_cells_mapnot_defined$b817f466-04d4-11eb-0a26-c1c667f9f7f7$c61f35ea-04d6-11eb-2503-17a79f8d0298$7c515a7a-04d5-11eb-0f36-4fcebff709d5$c4a8694a-04d4-11eb-1eef-c9e037e6b21f$393041ec-049f-11eb-3089-2faf378445f3$759bc42e-04ab-11eb-0ab1-b12e008c02a9$1491a078-04aa-11eb-0106-19a3cf1e94b0$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272upstream_cells_map@md_strstringMarkdown.AdmonitionMarkdown.MDMarkdown.CodeMarkdowngetindex$7335de44-042f-11eb-2873-8bceef722432precedence_heuristic cell_id$7335de44-042f-11eb-2873-8bceef722432downstream_cells_mapupstream_cells_map$406aabea-04a5-11eb-06b8-312879457c42precedence_heuristic cell_id$406aabea-04a5-11eb-06b8-312879457c42downstream_cells_mapinteract!$9c39974c-04a5-11eb-184d-317eb542452c$759bc42e-04ab-11eb-0ab1-b12e008c02a9$1491a078-04aa-11eb-0106-19a3cf1e94b0$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272upstream_cells_mapAgent$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2InfectionRecovery$1a654bdc-0421-11eb-2c38-7d35060e2565$c61f35ea-04d6-11eb-2503-17a79f8d0298precedence_heuristic cell_id$c61f35ea-04d6-11eb-2503-17a79f8d0298downstream_cells_mapupstream_cells_map@md_strBase.getindexextremaMissingrecovery_time$d57c6a5a-041b-11eb-3ab4-774a2d45a891:>!isless@isdefinedIntegerstill_missing$43e6e856-0414-11eb-19ca-07358aa8b667isa x isa Agent, result) keep_working(md"Make sure that you return an array of objects of the type `Agent`.") elseif length(result) != 4 almost(md"Make sure that you return `N` agents.") elseif length(Set(result)) != 4 almost(md"You returned the **same** agent `N` times. You need to call the `Agent` constructor `N` times, not once.") else if sum(a -> a.status == I, result) != 1 almost(md"Exactly one of the agents should be infectious.") else correct() end end end endmetadatashow_logsèdisabled®skip_as_script«code_folded$531d13c2-0414-11eb-0acd-4905a684869dcell_id$531d13c2-0414-11eb-0acd-4905a684869dcode٦if student.name == "Jazzy Doe" md""" !!! danger "Before you submit" Remember to fill in your **name** and **Kerberos ID** at the top of this notebook. """ endmetadatashow_logsèdisabled®skip_as_script«code_folded$06f30b2a-0403-11eb-0f05-8badebe1011dcell_id$06f30b2a-0403-11eb-0f05-8badebe1011dcodemd""" # **Homework 4**: _Epidemic modeling I_ `18.S191`, fall 2020 This notebook contains _built-in, live answer checks_! In some exercises you will see a coloured box, which runs a test case on your code, and provides feedback based on the result. Simply edit the code, run it, and the check runs again. _For MIT students:_ there will also be some additional (secret) test cases that will be run as part of the grading process, and we will look at your notebook and write comments. Feel free to ask questions! """metadatashow_logsèdisabled®skip_as_script«code_folded$9c39974c-04a5-11eb-184d-317eb542452ccell_id$9c39974c-04a5-11eb-184d-317eb542452ccode٢let agent = Agent(S, 0) source = Agent(I, 0) infection = InfectionRecovery(0.9, 0.5) interact!(agent, source, infection) (agent=agent, source=source) endmetadatashow_logsèdisabled®skip_as_script«code_folded$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1cell_id$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1code/frequencies_plot_with_maximum(large_experiment)metadatashow_logsèdisabled®skip_as_script«code_folded$06089d1e-0495-11eb-0ace-a7a7dc60e5b2cell_id$06089d1e-0495-11eb-0ace-a7a7dc60e5b2code,frequencies_plot_with_mean(large_experiment)metadatashow_logsèdisabled®skip_as_script«code_folded$15187690-0403-11eb-2dfd-fd924faa3513cell_id$15187690-0403-11eb-2dfd-fd924faa3513codePbegin Pkg.add(["Plots", "PlutoUI",]) using Plots plotly() using PlutoUI endmetadatashow_logsèdisabled®skip_as_script«code_folded$d8abd2f6-0416-11eb-1c2a-f9157d9760a7cell_id$d8abd2f6-0416-11eb-1c2a-f9157d9760a7code)small_experiment = do_experiment(0.5, 20)metadatashow_logsèdisabled®skip_as_script«code_folded$9374e63c-0493-11eb-0952-4b97512d7cdbcell_id$9374e63c-0493-11eb-0952-4b97512d7cdbcode*md""" Great! Feel free to experiment with this function, try giving it a different array as argument. Plots.jl is pretty clever, it even works with an array of strings! #### Exercise 1.4 Next, we want to **add a new element** to our plot: a vertical line. To demonstrate how this works, here we added a vertical line at the _maximum value_. To write this function, we first create a **base plot**, we then **modify** that plot to add the vertical line, and finally, we **return** the plot. More on this in [the next info box](#note_about_plotting). """metadatashow_logsèdisabled®skip_as_script«code_folded$2d3bba2a-04a8-11eb-2c40-87794b6aeeaccell_id$2d3bba2a-04a8-11eb-2c40-87794b6aeeaccodemd""" #### Exercise 2.5 👉 Write a function `interact!` that takes an affected `agent` of type `Agent`, an `source` of type `Agent` and an `infection` of type `InfectionRecovery`. It implements a single (one-sided) interaction between two agents: - If the `agent` is susceptible and the `source` is infectious, then the `source` infects our `agent` with the given infection probability. If the `source` successfully infects the other agent, then its `num_infected` record must be updated. - If the `agent` is infected then it recovers with the relevant probability. - Otherwise, nothing happens. $(html"") """metadatashow_logsèdisabled®skip_as_script«code_folded$dfb99ace-04cf-11eb-0739-7d694c837d59cell_id$dfb99ace-04cf-11eb-0739-7d694c837d59code٣md""" 👉 Allow $p_\text{infection}$ and $p_\text{recovery}$ to be changed interactively and find parameter values for which you observe an epidemic outbreak. """metadatashow_logsèdisabled®skip_as_script«code_folded$271ec5f0-041d-11eb-041b-db46ec1465e0cell_id$271ec5f0-041d-11eb-041b-db46ec1465e0codemd""" We have just defined a new type `InfectionStatus`, as well as names `S`, `I` and `R` that are the (only) possible values that a variable of this type can take. 👉 Define a variable `test_status` whose value is `S`. """metadatashow_logsèdisabled®skip_as_script«code_folded$7946d83a-04a0-11eb-224b-2b315e87bc84cell_id$7946d83a-04a0-11eb-224b-2b315e87bc84code:function generate_agents(N::Integer) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9cell_id$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9code3function bernoulli(p::Number) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$9635c944-0403-11eb-3982-4df509f6a556cell_id$9635c944-0403-11eb-3982-4df509f6a556codemd""" #### Exercse 3.4 👉 What are three *simple* ways in which you could characterise the magnitude (size) of the epidemic outbreak? Find approximate values of these quantities for one of the runs of your simulation. """metadatashow_logsèdisabled®skip_as_script«code_folded$f3f81172-041c-11eb-2b9b-e99b7b9400edcell_id$f3f81172-041c-11eb-2b9b-e99b7b9400edcode+md""" $(html"") > ### Note about plotting > > Plots.jl has an interesting property: a plot is an object, not an action. Functions like `plot`, `bar`, `histogram` don't draw anything on your screen - they just return a `Plots.Plot`. This is a struct that contains the _description_ of a plot (what data should be plotted in what way?), not the _picture_. > > So a Pluto cell with a single line, `plot(1:10)`, will show a plot, because the _result_ of the function `plot` is a `Plot` object, and Pluto just shows the result of a cell. > > ##### Modifying plots > Nice plots are often formed by overlaying multiple plots. In Plots.jl, this is done using the **modifying functions**: `plot!`, `bar!`, `vline!`, etc. These take an extra (first) argument: a previous plot to modify. > > For example, to plot the `sin`, `cos` and `tan` functions in the same view, we do: > ```julia > function sin_cos_plot() > T = -1.0:0.01:1.0 > > result = plot(T, sin.(T)) > plot!(result, T, cos.(T)) > plot!(result, T, tan.(T)) > > return result > end > ``` > > 💡 This example demonstrates a useful pattern to combine plots: > 1. Create a **new** plot and store it in a variable > 2. **Modify** that plot to add more elements > 3. Return the plot > > It is recommended that these 3 steps happen **within a single cell**. This can prevent some strange glitches when re-running cells. There are three ways to group expressions together into a single cell: `begin`, `let` and `function`. More on this [later](#function_begin_let)! """metadatashow_logsèdisabled®skip_as_script«code_folded$4ad11052-042c-11eb-3643-8b2b3e1269bccell_id$4ad11052-042c-11eb-3643-8b2b3e1269bccodemetadatashow_logsèdisabled®skip_as_script«code_folded$76d117d4-0403-11eb-05d2-c5ea47d06f43cell_id$76d117d4-0403-11eb-05d2-c5ea47d06f43codejmd""" 👉 Write a function `recovery_time(p)` that returns the time taken until the person recovers. """metadatashow_logsèdisabled®skip_as_script«code_folded$095cbf46-0403-11eb-0c37-35de9562cebccell_id$095cbf46-0403-11eb-0c37-35de9562cebccode# edit the code below to set your name and kerberos ID (i.e. email without @mit.edu) student = (name = "Jazzy Doe", kerberos_id = "jazz") # you might need to wait until all other cells in this notebook have completed running. # scroll around the page to see what's upmetadatashow_logsèdisabled®skip_as_script«code_folded$26e2978e-0435-11eb-0d61-25f552d2771ecell_id$26e2978e-0435-11eb-0d61-25f552d2771ecodemetadatashow_logsèdisabled®skip_as_script«code_folded$6de37d6c-0415-11eb-1b05-85ac820016c7cell_id$6de37d6c-0415-11eb-1b05-85ac820016c7code'md""" 👉 What happens for $p=1$? """metadatashow_logsèdisabled®skip_as_script«code_folded$18d308c4-0424-11eb-176d-49feec6889cfcell_id$18d308c4-0424-11eb-176d-49feec6889cfcodetest_agent = missingmetadatashow_logsèdisabled®skip_as_script«code_folded$46133a74-04b1-11eb-0b46-0bc74e564680cell_id$46133a74-04b1-11eb-0b46-0bc74e564680codeZfunction sweep!(agents::Vector{Agent}, infection::AbstractInfection) # your code here endmetadatashow_logsèdisabled®skip_as_script«code_folded$771c8f0c-0403-11eb-097e-ab24d0714ad5cell_id$771c8f0c-0403-11eb-097e-ab24d0714ad5code7md""" #### Exercise 1.3 👉 Write a function `frequencies(data)` that calculates and returns the frequencies (i.e. probability distribution) of input data. The input will be an array of integers, **with duplicates**, and the result will be a dictionary that maps each occured value to its frequency in the data. For example, ```julia frequencies([7, 8, 9, 7]) ``` should give ```julia Dict( 7 => 0.5, 8 => 0.25, 9 => 0.25 ) ``` As with any probability distribution, it should be normalised to $1$, in the sense that the *total* probability should be $1$. """metadatashow_logsèdisabled®skip_as_script«code_folded$80c2cd88-04b1-11eb-326e-0120a39405eacell_id$80c2cd88-04b1-11eb-326e-0120a39405eacodeOsimulations = repeat_simulations(100, 1000, InfectionRecovery(0.02, 0.002), 20)metadatashow_logsèdisabled®skip_as_script«code_folded$105d347e-041c-11eb-2fc8-1d9e5eda2be0cell_id$105d347e-041c-11eb-2fc8-1d9e5eda2be0code2function frequencies(values) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$2c62b4ae-04b3-11eb-0080-a1035a7e31a2cell_id$2c62b4ae-04b3-11eb-0080-a1035a7e31a2code4simulation(100, 1000, InfectionRecovery(0.005, 0.2))metadatashow_logsèdisabled®skip_as_script«code_folded$6db6c894-0415-11eb-305a-c75b119d89e9cell_id$6db6c894-0415-11eb-305a-c75b119d89e9codeDmd""" We should always be aware of special cases (sometimes called "boundary conditions"). Make sure *not* to run the code with $p=0$! What would happen in that case? Your code should check for this and throw an `ArgumentError` as follows: ```julia throw(ArgumentError("...")) ``` with a suitable error message. """metadatashow_logsèdisabled®skip_as_script«code_folded$77db111e-0403-11eb-2dea-4b42ceed65d6cell_id$77db111e-0403-11eb-2dea-4b42ceed65d6codeپmd""" #### Exercise 1.6 👉 Use $N = 10,000$ to calculate the mean time $\langle \tau(p) \rangle$ to recover as a function of $p$ between $0.001$ and $1$ (say). Plot this relationship. """metadatashow_logsèdisabled®skip_as_script«code_folded$3d88c056-0414-11eb-0025-05d3aff1588bcell_id$3d88c056-0414-11eb-0025-05d3aff1588bcodeYcorrect(text=rand(yays)) = Markdown.MD(Markdown.Admonition("correct", "Got it!", [text]))metadatashow_logsèdisabled®skip_as_script«code_folded$287ee7aa-0435-11eb-0ca3-951dbbe69404cell_id$287ee7aa-0435-11eb-0ca3-951dbbe69404codeٸfunction sir_mean_error_plot(simulations::Vector{<:NamedTuple}) # you might need T for this function, here's a trick to get it: T = length(first(simulations).S) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$03a85970-0403-11eb-334a-812b59c0905bcell_id$03a85970-0403-11eb-334a-812b59c0905bcodePmd""" Submission by: **_$(student.name)_** ($(student.kerberos_id)@mit.edu) """metadatashow_logsèdisabled®skip_as_script«code_folded$6d906d0c-0415-11eb-0c1c-b5c0aca841dbcell_id$6d906d0c-0415-11eb-0c1c-b5c0aca841dbcode{hint(md"Remember to always re-use work you have done previously: in this case you should re-use the function `bernoulli`.")metadatashow_logsèdisabled®skip_as_script«code_folded$866299e8-0403-11eb-085d-2b93459cc141cell_id$866299e8-0403-11eb-085d-2b93459cc141codeىmd""" 👉 We will also need functions `is_susceptible` and `is_infected` that check if a given agent is in those respective states. """metadatashow_logsèdisabled®skip_as_script«code_folded$461586dc-0414-11eb-00f3-4984b57bfac5cell_id$461586dc-0414-11eb-00f3-4984b57bfac5codeSalmost(text) = Markdown.MD(Markdown.Admonition("warning", "Almost there!", [text]))metadatashow_logsèdisabled®skip_as_script«code_folded$c5156c72-04af-11eb-1106-b13969b036cacell_id$c5156c72-04af-11eb-1106-b13969b036cacodelet run_basic_sir N = 100 T = 1000 sim = simulation(N, T, InfectionRecovery(0.02, 0.002)) result = plot(1:T, sim.S, ylim=(0, N), label="Susceptible") plot!(result, 1:T, sim.I, ylim=(0, N), label="Infectious") plot!(result, 1:T, sim.R, ylim=(0, N), label="Recovered") endmetadatashow_logsèdisabled®skip_as_script«code_folded$c4a8694a-04d4-11eb-1eef-c9e037e6b21fcell_id$c4a8694a-04d4-11eb-1eef-c9e037e6b21fcodeif !@isdefined(is_susceptible) not_defined(:is_susceptible) else let result1 = is_susceptible(Agent(I,2)) result2 = is_infected(Agent(I,2)) if result1 isa Missing || result2 isa Missing still_missing() elseif !(result1 isa Bool) || !(result2 isa Bool) keep_working(md"Make sure that you return either `true` or `false`.") elseif result1 === false && result2 === true if is_susceptible(Agent(S,3)) && !is_infected(Agent(R,9)) correct() else keep_working() end else keep_working() end end endmetadatashow_logsèdisabled®skip_as_script«code_folded$1491a078-04aa-11eb-0106-19a3cf1e94b0cell_id$1491a078-04aa-11eb-0106-19a3cf1e94b0codeif !@isdefined(interact!) not_defined(:interact!) else let agent = Agent(I, 9) source = Agent(S, 0) interact!(agent, source, InfectionRecovery(1.0, 1.0)) if source.status != S || source.num_infected != 0 keep_working(md"The `source` should not be modified if `agent` is infectious.") elseif agent.status != R keep_working(md"The `agent` should recover from an infectious state with the right probability.") elseif agent.num_infected != 9 keep_working(md"`agent.num_infected` should not be modified if `agent` is infectious.") else let agent = Agent(I, 9) source = Agent(R, 0) interact!(agent, source, InfectionRecovery(1.0, 0.0)) if agent.status == R keep_working(md"The `agent` should recover from an infectious state with the right probability.") else correct(md"Your function treats the **infectious** agent case correctly!") end end end end endmetadatashow_logsèdisabled®skip_as_script«code_folded$c5c7cb86-041b-11eb-3360-45463105f3c9cell_id$c5c7cb86-041b-11eb-3360-45463105f3c9code2function do_experiment(p, N) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$01341648-0403-11eb-2212-db450c299f35cell_id$01341648-0403-11eb-2212-db450c299f35codemd"_homework 4, version 1_"metadatashow_logsèdisabled®skip_as_script«code_folded$48a16c42-0414-11eb-0e0c-bf52bbb0f618cell_id$48a16c42-0414-11eb-0e0c-bf52bbb0f618codeEhint(text) = Markdown.MD(Markdown.Admonition("hint", "Hint", [text]))metadatashow_logsèdisabled®skip_as_script«code_folded$98beb336-0425-11eb-3886-4f8cfd210288cell_id$98beb336-0425-11eb-3886-4f8cfd210288codeWfunction set_status!(agent::Agent, new_status::InfectionStatus) # your code here endmetadatashow_logsèdisabled®skip_as_script«code_folded$bb63f3cc-042f-11eb-04ff-a128aec3c378cell_id$bb63f3cc-042f-11eb-04ff-a128aec3c378codemetadatashow_logsèdisabled®skip_as_script«code_folded$61c00724-0403-11eb-228d-17c11670e5d1cell_id$61c00724-0403-11eb-228d-17c11670e5d1codemd""" ## **Exercise 4:** _Reinfection_ In this exercise we will *re-use* our simulation infrastructure to study the dynamics of a different type of infection: there is no immunity, and hence no "recovery" rather, susceptible individuals may now be **re-infected** #### Exercise 4.1 👉 Make a new infection type `Reinfection`. This has the *same* two fields as `InfectionRecovery` (`p_infection` and `p_recovery`). However, "recovery" now means "becomes susceptible again", instead of "moves to the `R` class. This new type `Reinfection` should also be a **subtype** of `AbstractInfection`. This allows us to reuse our previous functions, which are defined for the abstract supertype. """metadatashow_logsèdisabled®skip_as_script«code_folded$9cf9080a-04b1-11eb-12a0-17013f2d37f5cell_id$9cf9080a-04b1-11eb-12a0-17013f2d37f5codemd""" 👉 Calculate the **mean number of infectious agents** of our simulations for each time step. Add it to the plot using a heavier line (`lw=3` for "linewidth") by modifying the cell above. Check the answer yourself: does your curve follow the average trend? $(hint(md"This exercise requires some creative juggling with arrays, anonymous functions, `map`s, or whatever you see fit!")) """metadatashow_logsèdisabled®skip_as_script«code_folded$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8cell_id$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8code[large_experiment = do_experiment(0.25, 10_000) # (10_000 is just 10000 but easier to read)metadatashow_logsèdisabled®skip_as_script«code_folded$61789646-0403-11eb-0042-f3b8308f11bacell_id$61789646-0403-11eb-0042-f3b8308f11bacode.md""" ## **Exercise 2:** _Agent-based model for an epidemic outbreak -- types_ In this and the following exercises we will develop a simple stochastic model for combined infection and recovery in a population, which may exhibit an **epidemic outbreak** (i.e. a large spike in the number of infectious people). The population is **well mixed**, i.e. everyone is in contact with everyone else. [An example of this would be a small school or university in which people are constantly moving around and interacting with each other.] The model is an **individual-based** or **agent-based** model: we explicitly keep track of each individual, or **agent**, in the population and their infection status. For the moment we will not keep track of their position in space; we will just assume that there is some mechanism, not included in the model, by which they interact with other individuals. #### Exercise 2.1 Each agent will have its own **internal state**, modelling its infection status, namely "susceptible", "infectious" or "recovered". We would like to code these as values `S`, `I` and `R`, respectively. One way to do this is using an [**enumerated type**](https://en.wikipedia.org/wiki/Enumerated_type) or **enum**. Variables of this type can take only a pre-defined set of values; the Julia syntax is as follows: """metadatashow_logsèdisabled®skip_as_script«code_folded$39dffa3c-0414-11eb-0197-e72b299e9c63cell_id$39dffa3c-0414-11eb-0197-e72b299e9c63code&bigbreak = html"




";metadatashow_logsèdisabled®skip_as_script«code_folded$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272cell_id$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272codeif !@isdefined(interact!) not_defined(:interact!) else let agent = Agent(R, 9) source = Agent(I, 0) interact!(agent, source, InfectionRecovery(1.0, 1.0)) if source.status != I || source.num_infected != 0 keep_working(md"The `source` should not be modified if no infection occured.") elseif agent.status != R || agent.num_infected != 9 keep_working(md"The `agent` should not be momdified if it is in a recoved state.") else correct(md"Your function treats the **recovered** agent case correctly!") end end endmetadatashow_logsèdisabled®skip_as_script«code_folded$88c53208-041d-11eb-3b1e-31b57ba99f05cell_id$88c53208-041d-11eb-3b1e-31b57ba99f05codemetadatashow_logsèdisabled®skip_as_script«code_folded$887d27fc-04bc-11eb-0ab9-eb95ef9607f8cell_id$887d27fc-04bc-11eb-0ab9-eb95ef9607f8codeٌfunction simulation(N::Integer, T::Integer, infection::AbstractInfection) # your code here return (S=missing, I=missing, R=missing) endmetadatashow_logsèdisabled®skip_as_script«code_folded$d57c6a5a-041b-11eb-3ab4-774a2d45a891cell_id$d57c6a5a-041b-11eb-3ab4-774a2d45a891codefunction recovery_time(p) if p ≤ 0 throw(ArgumentError("p must be positive: p = 0 cannot result in a recovery")) end # Your code here. See the comment below about the p ≤ 0 case. return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$12cc2940-0403-11eb-19a7-bb570de58f6fcell_id$12cc2940-0403-11eb-19a7-bb570de58f6fcode/begin using Pkg Pkg.activate(mktempdir()) endmetadatashow_logsèdisabled®skip_as_script«code_folded$76f62d64-0403-11eb-27e2-3de58366b619cell_id$76f62d64-0403-11eb-27e2-3de58366b619code٠md""" #### Exercise 1.2 👉 Write a function `do_experiment(p, N)` that runs the function `recovery_time` `N` times and collects the results into a vector. """metadatashow_logsèdisabled®skip_as_script«code_folded$860790fc-0403-11eb-2f2e-355f77dcc7afcell_id$860790fc-0403-11eb-2f2e-355f77dcc7afcodemd""" #### Exercise 2.2 For each agent we want to keep track of its infection status and the number of *other* agents that it infects during the simulation. A good solution for this is to define a *new type* `Agent` to hold all of the information for one agent, as follows: """metadatashow_logsèdisabled®skip_as_script«code_folded$b21475c6-04ac-11eb-1366-f3b5e967402dcell_id$b21475c6-04ac-11eb-1366-f3b5e967402dcodemd""" Play around with the test case below to test your function! Try changing the definitions of `agent`, `source` and `infection`. Since we are working with randomness, you might want to run the cell multiple times. """metadatashow_logsèdisabled®skip_as_script«code_folded$823364ce-041c-11eb-2467-7ffa4f751527cell_id$823364ce-041c-11eb-2467-7ffa4f751527codeٖfunction frequencies_plot_with_maximum(data::Vector) base = bar(frequencies(data)) vline!(base, [maximum(data)], label="maximum") return base endmetadatashow_logsèdisabled®skip_as_script«code_folded$619c8a10-0403-11eb-2e89-8b0974fb01d0cell_id$619c8a10-0403-11eb-2e89-8b0974fb01d0codemd""" ## **Exercise 3:** _Agent-based model for an epidemic outbreak -- Monte Carlo simulation_ In this exercise we will build on Exercise 2 to write a Monte Carlo simulation of how an infection propagates in a population. Make sure to re-use the functions that we have already written, and introduce new ones if they are helpful! Short functions make it easier to understand what the function does and build up new functionality piece by piece. You should not use any global variables inside the functions: Each function must accept as arguments all the information it requires to carry out its task. You need to think carefully about what the information each function requires. #### Exercise 3.1 👉 Write a function `step!` that takes a vector of `Agent`s and an `infection` of type `InfectionRecovery`. It implements a single step of the infection dynamics as follows: - Choose two random agents: an `agent` and a `source`. - Apply `interact!(agent, source, infection)`. - Return `agents`. """metadatashow_logsèdisabled®skip_as_script«code_folded$38b1aa5a-04cf-11eb-11a2-930741fc9076cell_id$38b1aa5a-04cf-11eb-11a2-930741fc9076codeٖfunction repeat_simulations(N, T, infection, num_simulations) N = 100 T = 1000 map(1:num_simulations) do _ simulation(N, T, infection) end endmetadatashow_logsèdisabled®skip_as_script«code_folded$8dd97820-04a5-11eb-36c0-8f92d4b859a8cell_id$8dd97820-04a5-11eb-36c0-8f92d4b859a8codemetadatashow_logsèdisabled®skip_as_script«code_folded$df8547b4-0400-11eb-07c6-fb370b61c2b6cell_id$df8547b4-0400-11eb-07c6-fb370b61c2b6codemd""" ## **Exercise 1:** _Modelling recovery_ In this exercise we will investigate a simple stochastic (probabilistic) model of recovery from an infection and the time $\tau$ needed to recover. Although this model can be easily studied analytically using probability theory, we will instead use computational methods. (If you know about this distribution already, try to ignore what you know about it!) In this model, an individual who is infected has a constant probability $p$ to recover each day. If they recover on day $n$ then $\tau$ takes the value $n$. Each time we run a new experiment $\tau$ will take on different values, so $\tau$ is a (discrete) random variable. We thus need to study statistical properties of $\tau$, such as its mean and its probability distribution. #### Exercise 1.1 - _Probability distributions_ 👉 Define the function `bernoulli(p)`, which returns `true` with probability $p$ and `false` with probability $(1 - p)$. """metadatashow_logsèdisabled®skip_as_script«code_folded$1d3356c4-0403-11eb-0f48-01b5eb14a585cell_id$1d3356c4-0403-11eb-0f48-01b5eb14a585codehtml""" """metadatashow_logsèdisabled®skip_as_script«code_folded$82f2580a-04c8-11eb-1eea-bdb4e50eee3bcell_id$82f2580a-04c8-11eb-1eea-bdb4e50eee3bcodeAgent()metadatashow_logsèdisabled®skip_as_script«code_folded$86d98d0a-0403-11eb-215b-c58ad721a90bcell_id$86d98d0a-0403-11eb-215b-c58ad721a90bcode,md""" We will also need types representing different infections. Let's define an (immutable) `struct` called `InfectionRecovery` with parameters `p_infection` and `p_recovery`. We will make it a subtype of an abstract `AbstractInfection` type, because we will define more infection types later. """metadatashow_logsèdisabled®skip_as_script«code_folded$dc784864-0430-11eb-1478-d1153e017310cell_id$dc784864-0430-11eb-1478-d1153e017310codemd""" The frequencies dictionary is difficult to interpret on its own, so instead, we will **plot** it, i.e. plot $P(\tau = n)$ against $n$, where $n$ is the recovery time. Plots.jl comes with a function `bar`, which does exactly what we want: """metadatashow_logsèdisabled®skip_as_script«code_folded$3f5e0af8-0414-11eb-34a7-a71e7aaf6443cell_id$3f5e0af8-0414-11eb-34a7-a71e7aaf6443codeyays = [md"Fantastic!", md"Splendid!", md"Great!", md"Yay ❤", md"Great! 🎉", md"Well done!", md"Keep it up!", md"Good job!", md"Awesome!", md"You got the right answer!", md"Let's move on to the next section."]metadatashow_logsèdisabled®skip_as_script«code_folded$3c0528a0-0414-11eb-2f68-a5657ab9e73dcell_id$3c0528a0-0414-11eb-2f68-a5657ab9e73dcodeٱnot_defined(variable_name) = Markdown.MD(Markdown.Admonition("danger", "Oopsie!", [md"Make sure that you define a variable called **$(Markdown.Code(string(variable_name)))**"]))metadatashow_logsèdisabled®skip_as_script«code_folded$7335de44-042f-11eb-2873-8bceef722432cell_id$7335de44-042f-11eb-2873-8bceef722432codemetadatashow_logsèdisabled®skip_as_script«code_folded$406aabea-04a5-11eb-06b8-312879457c42cell_id$406aabea-04a5-11eb-06b8-312879457c42codecfunction interact!(agent::Agent, source::Agent, infection::InfectionRecovery) # your code here endmetadatashow_logsèdisabled®skip_as_script«code_folded$c61f35ea-04d6-11eb-2503-17a79f8d0298cell_id$c61f35ea-04d6-11eb-2503-17a79f8d0298code4if !@isdefined(recovery_time) not_defined(:recovery_time) else let result = recovery_time(1.0) if result isa Missing still_missing() elseif !(result isa Integer) keep_working(md"Make sure that you return an integer: the recovery time.") else if result == 1 samples = [recovery_time(0.2) for _ in 1:256] a, b = extrema(samples) if a == 1 && b > 20 correct() else keep_working() end else keep_working(md"`p = 1.0` should return `1`: the agent recovers after the first time step.") end end end endmetadatashow_logsèdisabled®skip_as_script«code_folded$9cd2bb00-04b1-11eb-1d83-a703907141a7cell_id$9cd2bb00-04b1-11eb-1d83-a703907141a7codejlet p = plot() for sim in simulations plot!(p, 1:1000, sim.I, alpha=.5, label=nothing) end p endmetadatashow_logsèdisabled®skip_as_script«code_folded$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bcell_id$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bcode"bar(frequencies(large_experiment))metadatashow_logsèdisabled®skip_as_script«code_folded$8631a536-0403-11eb-0379-bb2e56927727cell_id$8631a536-0403-11eb-0379-bb2e56927727codemd""" #### Exercise 2.3 👉 Write functions `set_status!(a)` and `set_num_infected!(a)` which modify the respective fields of an `Agent`. Check that they work. [Note the bang ("`!`") at the end of the function names to signify that these functions *modify* their argument.] """metadatashow_logsèdisabled®skip_as_script«code_folded$9a13b17c-0403-11eb-024f-9b37e95e211bcell_id$9a13b17c-0403-11eb-024f-9b37e95e211bcodemd""" #### Exercise 4.2 👉 Run the simulation 20 times and plot $I$ as a function of time for each one, together with the mean over the 20 simulations (as you did in the previous exercises). Note that you should be able to re-use the `sweep!` and `simulation` functions , since those should be sufficiently **generic** to work with the new `step!` function! (Modify them if they are not.) """metadatashow_logsèdisabled®skip_as_script«code_folded$b92f1cec-04ae-11eb-0072-3535d1118494cell_id$b92f1cec-04ae-11eb-0072-3535d1118494code.simulation(3, 20, InfectionRecovery(0.9, 0.2))metadatashow_logsèdisabled®skip_as_script«code_folded$9a377b32-0403-11eb-2799-e7e59caa6a45cell_id$9a377b32-0403-11eb-2799-e7e59caa6a45code٭md""" 👉 Run the new simulation and draw $I$ (averaged over runs) as a function of time. Is the behaviour qualitatively the same or different? Describe what you see. """metadatashow_logsèdisabled®skip_as_script«code_folded$778ec25c-0403-11eb-3146-1d11c294bb1fcell_id$778ec25c-0403-11eb-3146-1d11c294bb1fcodeٔmd""" #### Exercise 1.5 👉 What shape does the distribution seem to have? Can you verify that by adding a second plot with the expected shape? """metadatashow_logsèdisabled®skip_as_script«code_folded$9611ca24-0403-11eb-3582-b7e3bb243e62cell_id$9611ca24-0403-11eb-3582-b7e3bb243e62codemd""" #### Exercise 3.3 👉 Plot the probability distribution of `num_infected`. Does it have a recognisable shape? (Feel free to increase the number of agents in order to get better statistics.) """metadatashow_logsèdisabled®skip_as_script«code_folded$26f84600-041d-11eb-1856-b12a3e5c1dc7cell_id$26f84600-041d-11eb-1856-b12a3e5c1dc7code@enum InfectionStatus S I Rmetadatashow_logsèdisabled®skip_as_script«code_folded$1ca7a8c2-041a-11eb-146a-15b8cdeaea72cell_id$1ca7a8c2-041a-11eb-146a-15b8cdeaea72codefrequencies(small_experiment)metadatashow_logsèdisabled®skip_as_script«code_folded$190deebc-0424-11eb-19fe-615997093e14cell_id$190deebc-0424-11eb-19fe-615997093e14code?md""" 👉 For convenience, define a new constructor (i.e. a new method for the function) that takes no arguments and creates an `Agent` with status `S` and number infected 0, by calling one of the default constructors that Julia creates. This new method lives *outside* (not inside) the definition of the `struct`. (It is called an **outer constructor**.) (In Pluto, multiple methods for the same function need to be combined in a single cell using a `begin end` block.) Let's check that the new method works correctly. How many methods does the constructor have now? """metadatashow_logsèdisabled®skip_as_script«code_folded$1a654bdc-0421-11eb-2c38-7d35060e2565cell_id$1a654bdc-0421-11eb-2c38-7d35060e2565codeJstruct InfectionRecovery <: AbstractInfection p_infection p_recovery endmetadatashow_logsèdisabled®skip_as_script«code_folded$41cefa68-0414-11eb-3bad-6530360d6f68cell_id$41cefa68-0414-11eb-3bad-6530360d6f68codeفkeep_working(text=md"The answer is not quite right.") = Markdown.MD(Markdown.Admonition("danger", "Keep working on it!", [text]))metadatashow_logsèdisabled®skip_as_script«code_folded$847d0fc2-041d-11eb-2864-79066e223b45cell_id$847d0fc2-041d-11eb-2864-79066e223b45codeـmd""" 👉 Convert `x` to an integer using the `Integer` function. What value does it have? What values do `I` and `R` have? """metadatashow_logsèdisabled®skip_as_script«code_folded$77428072-0403-11eb-0068-81e3728f2ebecell_id$77428072-0403-11eb-0068-81e3728f2ebecode?md""" Let's run an experiment with $p=0.25$ and $N=10,000$. """metadatashow_logsèdisabled®skip_as_script«code_folded$9a837b52-0425-11eb-231f-a74405ff6e23cell_id$9a837b52-0425-11eb-231f-a74405ff6e23code;function is_susceptible(agent::Agent) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded$0a967f38-0493-11eb-0624-77e40b24d757cell_id$0a967f38-0493-11eb-0624-77e40b24d757codemd""" We used a `let` block in this cell to group multiple expressions together, but how is it different from `begin` or `function`? $(html"") > ##### _**function**_ vs. _**begin**_ vs. _**let**_ > Writing functions is a way to group multiple expressions (i.e. lines of code) together into a mini-program. Note the following about functions: > - A function always returns **one object**.[^1] This object can be given explicitly by writing `return x`, or implicitly: Julia functions always return the result of the last expression by default. So `f(x) = x+2` is the same as `f(x) = return x+2`. > - Variables defined inside a function are _not accessible outside the function_. We say that function bodies have a **local scope**. This helps to keep your program easy to read and write: if you define a local variable, then you don't need to worry about it in the rest of the notebook. > > There are two other ways to group epxressions together that you might have seen before: `begin` and `let`. > > ###### begin > **`begin`** will group expressions together, and it takes the value of its last subexpression. > > We use it in this notebook when we want multiple expressions to always run together. > > ###### let > **`let`** also groups multiple expressions together into one, but variables defined inside of it are **local**: they don't affect code outside of the block. So like `begin`, it is just a block of code, but like `function`, it has a local variable scope. > > We use it when we want to define some local (temporary) variables to produce a complicated result, without interfering with other cells. Pluto allows only one definition per _global_ variable of the same name, but you can define _local_ variables with the same names whenever you wish! > > [^1]: Even a function like > > `f(x) = return` > > returns **one object**: the object `nothing` — try it out! """metadatashow_logsèdisabled®skip_as_script«code_folded$28db9d98-04ca-11eb-3606-9fb89fa62f36cell_id$28db9d98-04ca-11eb-3606-9fb89fa62f36code3@bind run_basic_sir Button("Run simulation again!")metadatashow_logsèdisabled®skip_as_script«code_folded$8692bf42-0403-11eb-191f-b7d08895274fcell_id$8692bf42-0403-11eb-191f-b7d08895274fcodemd""" #### Exericse 2.4 👉 Write a function `generate_agents(N)` that returns a vector of `N` freshly created `Agent`s. They should all be initially susceptible, except one, chosen at random (i.e. uniformly), who is infectious. """metadatashow_logsèdisabled®skip_as_script«code_folded$da49710e-0420-11eb-092e-4f1173868738cell_id$da49710e-0420-11eb-092e-4f1173868738codemd""" ## **Exercise 5** - _Lecture transcript_ (MIT students only) Please see the link for hw 4 transcript document on [Canvas](https://canvas.mit.edu/courses/5637). We want each of you to correct about 400 lines, but don’t spend more than 15 minutes on it. See the the beginning of the document for more instructions. :point_right: Please mention the name of the video(s) and the line ranges you edited: """metadatashow_logsèdisabled®skip_as_script«code_folded$7bb8e426-0495-11eb-3a8b-cbbab61a1631cell_id$7bb8e426-0495-11eb-3a8b-cbbab61a1631codemetadatashow_logsèdisabled®skip_as_script«code_folded$21c50840-0435-11eb-1307-7138ecde0691cell_id$21c50840-0435-11eb-1307-7138ecde0691codemetadatashow_logsèdisabled®skip_as_script«code_folded$2ade2694-0425-11eb-2fb2-390da43d9695cell_id$2ade2694-0425-11eb-2fb2-390da43d9695codeYfunction step!(agents::Vector{Agent}, infection::AbstractInfection) # your code here endmetadatashow_logsèdisabled®skip_as_script«code_folded$bf6fd176-04cc-11eb-008a-2fb6ff70a9cbcell_id$bf6fd176-04cc-11eb-008a-2fb6ff70a9cbcode?md""" #### Exercise 3.2 Alright! Every time that we run the simulation, we get slightly different results, because it is based on randomness. By running the simulation a number of times, you start to get an idea of the _mean behaviour_ of our model. This is the essence of a Monte Carlo method! You use computer-generated randomness to generate samples. Instead of pressing the button many times, let's have the computer repeat the simulation. In the next cells, we run your simulation `num_simulations=20` times with $N=100$, $p_\text{infection} = 0.02$, $p_\text{infection} = 0.002$ and $T = 1000$. Every single simulation returns a named tuple with the status counts, so the result of multiple simulations will be an array of those. Have a look inside the result, `simulations`, and make sure that its structure is clear. """metadatashow_logsèdisabled®skip_as_script«code_folded$73047bba-0416-11eb-1047-23e9c3dbde05cell_id$73047bba-0416-11eb-1047-23e9c3dbde05code4interpretation_of_p_equals_one = md""" blablabla """metadatashow_logsèdisabled®skip_as_script«code_folded$43e6e856-0414-11eb-19ca-07358aa8b667cell_id$43e6e856-0414-11eb-19ca-07358aa8b667codeـstill_missing(text=md"Replace `missing` with your answer.") = Markdown.MD(Markdown.Admonition("warning", "Here we go!", [text]))metadatashow_logsèdisabled®skip_as_script«code_folded$2b26dc42-0403-11eb-205f-cd2c23d8cb03cell_id$2b26dc42-0403-11eb-205f-cd2c23d8cb03codebigbreakmetadatashow_logsèdisabled®skip_as_script«code_folded$95c598d4-0403-11eb-2328-0175ed564915cell_id$95c598d4-0403-11eb-2328-0175ed564915codeٍmd""" 👉 Write a function `sir_mean_plot` that returns a plot of the means of $S$, $I$ and $R$ as a function of time on a single graph. """metadatashow_logsèdisabled®skip_as_script«code_folded$1ac4b33a-0435-11eb-36f8-8f3f81ae7844cell_id$1ac4b33a-0435-11eb-36f8-8f3f81ae7844codemetadatashow_logsèdisabled®skip_as_script«code_folded$a8dd5cae-0425-11eb-119c-bfcbf832d695cell_id$a8dd5cae-0425-11eb-119c-bfcbf832d695code8function is_infected(agent::Agent) return missing endmetadatashow_logsèdisabled®skip_as_script«code_folded«notebook_id$efbd3a58-4aa6-11f0-3049-afe95b0c5665in_temp_dir¨metadata