Þ¥bonds€¬cell_resultsÞ€Ù$f1f89502-0494-11eb-2303-0b79d8bbd13fЦqueued¤logs�§running¦output†¤bodyÙ;frequencies_plot_with_mean (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊnd˰persist_js_state·has_pluto_hook_features§cell_idÙ$f1f89502-0494-11eb-2303-0b79d8bbd13f¹depends_on_disabled_cells§runtimeÎ�„µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$95771ce2-0403-11eb-3056-f1dc3a8b7ec3Цqueued¤logs�§running¦output†¤bodyÚh

👉 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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄtn“°persist_js_state·has_pluto_hook_features§cell_idÙ$95771ce2-0403-11eb-3056-f1dc3a8b7ec3¹depends_on_disabled_cells§runtimeÎ „µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$e6219c7c-0420-11eb-3faa-13126f7c8007Цqueued¤logs�§running¦output†¤bodyÙ¤

Abstraction, lines 1-219

Array Basics, lines 1-137

Course Intro, lines 1-44

(for example)

¤mime©text/html¬rootassignee®lines_i_edited²last_run_timestampËAÚË÷®X°persist_js_state·has_pluto_hook_features§cell_idÙ$e6219c7c-0420-11eb-3faa-13126f7c8007¹depends_on_disabled_cells§runtimeÎ=�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b817f466-04d4-11eb-0a26-c1c667f9f7f7Цqueued¤logs�§running¦output†¤bodyÙ¥

Here we go!

Replace missing with your answer.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌS°persist_js_state·has_pluto_hook_features§cell_idÙ$b817f466-04d4-11eb-0a26-c1c667f9f7f7¹depends_on_disabled_cells§runtimeÎò—µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$08e2bc64-0417-11eb-1457-21c0d18e8c51Цqueued¤logs�§running¦output†¤bodyÚ�

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌ [Õ°persist_js_state·has_pluto_hook_features§cell_idÙ$08e2bc64-0417-11eb-1457-21c0d18e8c51¹depends_on_disabled_cells§runtimeΕ¯µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$bb8aeb58-042f-11eb-18b8-f995631df619Цqueued¤logs�§running¦output†¤bodyÙÑ

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄqãó°persist_js_state·has_pluto_hook_features§cell_idÙ$bb8aeb58-042f-11eb-18b8-f995631df619¹depends_on_disabled_cells§runtimeΘ�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$223933a4-042c-11eb-10d3-852229f25a35Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ«¬Þ°persist_js_state·has_pluto_hook_features§cell_idÙ$223933a4-042c-11eb-10d3-852229f25a35¹depends_on_disabled_cells§runtimeÎÿµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ{ru°persist_js_state·has_pluto_hook_features§cell_idÙ$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2¹depends_on_disabled_cells§runtimeΓ¦µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7f635722-04d0-11eb-3209-4b603c9e843cЦqueued¤logs�§running¦output†¤body‚£msgÚQMethodError: 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  ...ªstacktrace’Œªcall_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#L1¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#843fd63c-04d0-11eb-0113-c58d346179d6®source_packageÀ¤callÙ^sir_mean_plot(simulations::Vector{NamedTuple{(:S, :I, :R), Tuple{Missing, Missing, Missing}}})ªlinfo_type³Core.MethodInstance¤line¤fileÙ.hw4.jl#==#843fd63c-04d0-11eb-0113-c58d346179d6¤func­sir_mean_plot­parent_moduleÀ¦from_cÂŒªcall_short¯top-level scope§inlinedãurlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#7f635722-04d0-11eb-3209-4b603c9e843c®source_packageÀ¤call¯top-level scopeªlinfo_type§Nothing¤line¤fileÙ.hw4.jl#==#7f635722-04d0-11eb-3209-4b603c9e843c¤func»##function_wrapped_cell#413­parent_moduleÀ¦from_c¤mimeÙ'application/vnd.pluto.stacktrace+object¬rootassigneeÀ²last_run_timestampËAÚËì©ß°persist_js_state·has_pluto_hook_features§cell_idÙ$7f635722-04d0-11eb-3209-4b603c9e843c¹depends_on_disabled_cells§runtimeÀµpublished_object_keys�¸depends_on_skipped_cells§erroredÃÙ$7c515a7a-04d5-11eb-0f36-4fcebff709d5Цqueued¤logs�§running¦output†¤bodyÙœ

Keep working on it!

The answer is not quite right.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌVcZ°persist_js_state·has_pluto_hook_features§cell_idÙ$7c515a7a-04d5-11eb-0f36-4fcebff709d5¹depends_on_disabled_cells§runtimeÍÛµµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$107e65a4-0403-11eb-0c14-37d8d828b469Цqueued¤logs�§running¦output†¤bodyÙT

Let's create a package environment:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄpIs°persist_js_state·has_pluto_hook_features§cell_idÙ$107e65a4-0403-11eb-0c14-37d8d828b469¹depends_on_disabled_cells§runtimeÎPbµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄv#°persist_js_state·has_pluto_hook_features§cell_idÙ$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0¹depends_on_disabled_cells§runtimeÎnµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bbЦqueued¤logs�§running¦output†¤bodyÚ

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).

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄuß°persist_js_state·has_pluto_hook_features§cell_idÙ$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bb¹depends_on_disabled_cells§runtimeÎ`ñµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7f4e121c-041d-11eb-0dff-cd0cbfdfd606Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee«test_status²last_run_timestampËAÚÊr½^°persist_js_state·has_pluto_hook_features§cell_idÙ$7f4e121c-041d-11eb-0dff-cd0cbfdfd606¹depends_on_disabled_cells§runtimeÍ(úµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4f19e872-0414-11eb-0dfd-e53d2aecc4dcЦqueued¤logs�§running¦output†¤bodyÙn

Function library

Just some helper functions used in the notebook.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄwy¯°persist_js_state·has_pluto_hook_features§cell_idÙ$4f19e872-0414-11eb-0dfd-e53d2aecc4dc¹depends_on_disabled_cells§runtimeÎa¥µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$5689841e-0414-11eb-0492-63c77ddbd136Цqueued¤logs�§running¦output†¤body´




¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌxç°persist_js_state·has_pluto_hook_features§cell_idÙ$5689841e-0414-11eb-0492-63c77ddbd136¹depends_on_disabled_cells§runtimeÍ$¢µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9Цqueued¤logs�§running¦output†¤bodyÙØ

Keep working on it!

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌ`ä›°persist_js_state·has_pluto_hook_features§cell_idÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9¹depends_on_disabled_cells§runtimeÎí<µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$99ef7b2a-0403-11eb-08ef-e1023cd151aeЦqueued¤logs�§running¦output†¤bodyÚ¤

👉 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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄv뎰persist_js_state·has_pluto_hook_features§cell_idÙ$99ef7b2a-0403-11eb-08ef-e1023cd151ae¹depends_on_disabled_cells§runtimeÎM¨µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$77b54c10-0403-11eb-16ad-65374d29a817Цqueued¤logs�§running¦output†¤bodyÚ

👉 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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄq¨?°persist_js_state·has_pluto_hook_features§cell_idÙ$77b54c10-0403-11eb-16ad-65374d29a817¹depends_on_disabled_cells§runtimeÎ µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7768a2dc-0403-11eb-39b7-fd660dc952feЦqueued¤logs�§running¦output†¤bodyÙ²

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄqŽÖ°persist_js_state·has_pluto_hook_features§cell_idÙ$7768a2dc-0403-11eb-39b7-fd660dc952fe¹depends_on_disabled_cells§runtimeÎþQµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$60a8b708-04c8-11eb-37b1-3daec644ac90Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄsI°persist_js_state·has_pluto_hook_features§cell_idÙ$60a8b708-04c8-11eb-37b1-3daec644ac90¹depends_on_disabled_cells§runtimeÎ!¯µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$95eb9f88-0403-11eb-155b-7b2d3a07cff0Цqueued¤logs�§running¦output†¤bodyÚO

👉 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!

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄv?O°persist_js_state·has_pluto_hook_features§cell_idÙ$95eb9f88-0403-11eb-155b-7b2d3a07cff0¹depends_on_disabled_cells§runtimeÎìüµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$955321de-0403-11eb-04ce-fb1670dfbb9eЦqueued¤logs�§running¦output†¤bodyÚC

👉 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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄtIM°persist_js_state·has_pluto_hook_features§cell_idÙ$955321de-0403-11eb-04ce-fb1670dfbb9e¹depends_on_disabled_cells§runtimeÎyfµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$ae70625a-041f-11eb-3082-0753419d6d57Цqueued¤logs�§running¦output†¤bodyÚ“

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄrúv°persist_js_state·has_pluto_hook_features§cell_idÙ$ae70625a-041f-11eb-3082-0753419d6d57¹depends_on_disabled_cells§runtimeÎaµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$843fd63c-04d0-11eb-0113-c58d346179d6Цqueued¤logs�§running¦output†¤bodyÙ.sir_mean_plot (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚËàÑò°persist_js_state·has_pluto_hook_features§cell_idÙ$843fd63c-04d0-11eb-0113-c58d346179d6¹depends_on_disabled_cells§runtimeÎ h%µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$189cae1e-0424-11eb-2666-65bf297d8bddЦqueued¤logs�§running¦output†¤bodyÙ•

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄs&c°persist_js_state·has_pluto_hook_features§cell_idÙ$189cae1e-0424-11eb-2666-65bf297d8bdd¹depends_on_disabled_cells§runtimeÎuáµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7f744644-041d-11eb-08a0-3719cc0adeb7Цqueued¤logs�§running¦output†¤bodyÙ{

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄr—ò°persist_js_state·has_pluto_hook_features§cell_idÙ$7f744644-041d-11eb-08a0-3719cc0adeb7¹depends_on_disabled_cells§runtimeÎú5µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$488771e2-049f-11eb-3b0a-0de260457731Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ«Œü°persist_js_state·has_pluto_hook_features§cell_idÙ$488771e2-049f-11eb-3b0a-0de260457731¹depends_on_disabled_cells§runtimeÍ)ôµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$393041ec-049f-11eb-3089-2faf378445f3Цqueued¤logs�§running¦output†¤bodyÙ¥

Here we go!

Replace missing with your answer.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌY´¯°persist_js_state·has_pluto_hook_features§cell_idÙ$393041ec-049f-11eb-3089-2faf378445f3¹depends_on_disabled_cells§runtimeÎdäµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$531d13c2-0414-11eb-0acd-4905a684869dЦqueued¤logs�§running¦output†¤bodyÙç

Before you submit

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚËú °persist_js_state·has_pluto_hook_features§cell_idÙ$531d13c2-0414-11eb-0acd-4905a684869d¹depends_on_disabled_cells§runtimeÎTYµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$06f30b2a-0403-11eb-0f05-8badebe1011dЦqueued¤logs�§running¦output†¤bodyÚu

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!

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄp0×°persist_js_state·has_pluto_hook_features§cell_idÙ$06f30b2a-0403-11eb-0f05-8badebe1011d¹depends_on_disabled_cells§runtimeζfµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9c39974c-04a5-11eb-184d-317eb542452cЦqueued¤logs�§running¦output†¤bodyƒ¨elements’’¥agent’…¦prefix¥Agent¨elements’’¦status’¶S::InfectionStatus = 0ªtext/plain’¬num_infected’¡0ªtext/plain¤type¦struct¬prefix_short¥Agent¨objectid°8f17d8b939254d92Ù!application/vnd.pluto.tree+object’¦source’…¦prefix¥Agent¨elements’’¦status’¶I::InfectionStatus = 1ªtext/plain’¬num_infected’¡0ªtext/plain¤type¦struct¬prefix_short¥Agent¨objectid°709f2124fc33ddc2Ù!application/vnd.pluto.tree+object¤typeªNamedTuple¨objectid°7ce78337241724ae¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÚÊÏ ×°persist_js_state·has_pluto_hook_features§cell_idÙ$9c39974c-04a5-11eb-184d-317eb542452c¹depends_on_disabled_cells§runtimeÍŸ µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1Цqueued¤logs�§running¦output†¤body‚£msgÙûMethodError: 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:1ªstacktrace‘Œªcall_short¯top-level scope§inlinedãurlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#1ddbaa18-0494-11eb-1fc8-250ab6ae89f1®source_packageÀ¤call¯top-level scopeªlinfo_type§Nothing¤line¤fileÙ.hw4.jl#==#1ddbaa18-0494-11eb-1fc8-250ab6ae89f1¤func»##function_wrapped_cell#332­parent_moduleÀ¦from_c¤mimeÙ'application/vnd.pluto.stacktrace+object¬rootassigneeÀ²last_run_timestampËAÚÊcâç°persist_js_state·has_pluto_hook_features§cell_idÙ$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1¹depends_on_disabled_cells§runtimeÀµpublished_object_keys�¸depends_on_skipped_cells§erroredÃÙ$06089d1e-0495-11eb-0ace-a7a7dc60e5b2Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊnÚõ°persist_js_state·has_pluto_hook_features§cell_idÙ$06089d1e-0495-11eb-0ace-a7a7dc60e5b2¹depends_on_disabled_cells§runtimeÍ/úµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$15187690-0403-11eb-2dfd-fd924faa3513Цqueued¤logs’ˆ¤lineÿ£msg’Ù;Failed to load integration with PlotlyBase & PlotlyKaleido.ªtext/plain§cell_idÙ$15187690-0403-11eb-2dfd-fd924faa3513¦kwargs‘’©exception’‚£msgÙŠArgumentError: Package PlotlyBase not found in current path: - Run `import Pkg; Pkg.add("PlotlyBase")` to install the PlotlyBase package. ªstacktrace˜Œªcall_shortÙ"require(into::Module, mod::Symbol)§inlined£urlÙehttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/loading.jl#L959¤path¬./loading.jl®source_packageÀ¤callÙ"require(into::Module, mod::Symbol)ªlinfo_type³Core.MethodInstance¤lineÍǤfileªloading.jl¤func§require­parent_moduleÀ¦from_cÂŒªcall_short¯top-level scope§inlined£urlÀ¤pathÙ8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jl®source_packageÀ¤call¯top-level scopeªlinfo_type­Core.CodeInfo¤lineÍ8¤file«backends.jl¤func¯top-level scope­parent_moduleÀ¦from_cÂŒªcall_short¤eval§inlinedãurlÀ¤path©./boot.jl®source_packageÀ¤call¤evalªlinfo_type§Nothing¤lineÍu¤file§boot.jl¤func¤eval­parent_moduleÀ¦from_cÂŒªcall_shortÙ-_initialize_backend(pkg::Plots.PlotlyBackend)§inlined£urlÙ?file:///home/runner/.julia/packages/Plots/uiCPf/src/backends.jl¤pathÙ8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jl®source_packageÀ¤callÙ-_initialize_backend(pkg::Plots.PlotlyBackend)ªlinfo_type³Core.MethodInstance¤lineÍ7¤file«backends.jl¤func³_initialize_backend­parent_moduleÀ¦from_cÂŒªcall_shortÙ!backend(pkg::Plots.PlotlyBackend)§inlined£urlÙ?file:///home/runner/.julia/packages/Plots/uiCPf/src/backends.jl¤pathÙ8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jl®source_packageÀ¤callÙ!backend(pkg::Plots.PlotlyBackend)ªlinfo_type³Core.MethodInstance¤lineÌõ¤file«backends.jl¤func§backend­parent_moduleÀ¦from_cÂŒªcall_short«#plotly#324§inlinedãurlÀ¤pathÙ8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jl®source_packageÀ¤call«#plotly#324ªlinfo_type§Nothing¤lineV¤file«backends.jl¤func«#plotly#324­parent_moduleÀ¦from_cÂŒªcall_short¨plotly()§inlined£urlÙ?file:///home/runner/.julia/packages/Plots/uiCPf/src/backends.jl¤pathÙ8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jl®source_packageÀ¤call¨plotly()ªlinfo_type³Core.MethodInstance¤lineV¤file«backends.jl¤func¦plotly­parent_moduleÀ¦from_cÂŒªcall_short¯top-level scope§inlined£urlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#15187690-0403-11eb-2dfd-fd924faa3513®source_packageÀ¤call¯top-level scopeªlinfo_type­Core.CodeInfo¤line¤fileÙ.hw4.jl#==#15187690-0403-11eb-2dfd-fd924faa3513¤func¯top-level scope­parent_moduleÀ¦from_cÂÙ'application/vnd.pluto.stacktrace+object¢id®Plots_b627f5e6¤fileÙ8/home/runner/.julia/packages/Plots/uiCPf/src/backends.jl¥group¨backends¥level¤Warnˆ¤lineÿ£msg’Ú)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/plain§cell_idÙ$15187690-0403-11eb-2dfd-fd924faa3513¦kwargs�¢id´PlutoRunner_d1acb81e¤fileÙP/home/runner/.julia/packages/Pluto/6smog/src/runner/PlutoRunner/src/io/stdout.jl¥group¦stdout¥level®LogLevel(-555)§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÉI°persist_js_state·has_pluto_hook_features§cell_idÙ$15187690-0403-11eb-2dfd-fd924faa3513¹depends_on_disabled_cells§runtimeÏ ”I/µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d8abd2f6-0416-11eb-1c2a-f9157d9760a7Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee°small_experiment²last_run_timestampËAÚɲI°persist_js_state·has_pluto_hook_features§cell_idÙ$d8abd2f6-0416-11eb-1c2a-f9157d9760a7¹depends_on_disabled_cells§runtimeÍ7’µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9374e63c-0493-11eb-0952-4b97512d7cdbЦqueued¤logs�§running¦output†¤bodyÚ¢

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄqX°°persist_js_state·has_pluto_hook_features§cell_idÙ$9374e63c-0493-11eb-0952-4b97512d7cdb¹depends_on_disabled_cells§runtimeÎw.µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2d3bba2a-04a8-11eb-2c40-87794b6aeeacЦqueued¤logs�§running¦output†¤bodyÚy

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:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄsÎ!°persist_js_state·has_pluto_hook_features§cell_idÙ$2d3bba2a-04a8-11eb-2c40-87794b6aeeac¹depends_on_disabled_cells§runtimeÎ ®µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$dfb99ace-04cf-11eb-0739-7d694c837d59Цqueued¤logs�§running¦output†¤bodyÚ

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄv™°persist_js_state·has_pluto_hook_features§cell_idÙ$dfb99ace-04cf-11eb-0739-7d694c837d59¹depends_on_disabled_cells§runtimeÎ2Sµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$271ec5f0-041d-11eb-041b-db46ec1465e0Цqueued¤logs�§running¦output†¤bodyÚN

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄr€°persist_js_state·has_pluto_hook_features§cell_idÙ$271ec5f0-041d-11eb-041b-db46ec1465e0¹depends_on_disabled_cells§runtimeÎ Œµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7946d83a-04a0-11eb-224b-2b315e87bc84Цqueued¤logs�§running¦output†¤bodyÙ0generate_agents (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ«æ°persist_js_state·has_pluto_hook_features§cell_idÙ$7946d83a-04a0-11eb-224b-2b315e87bc84¹depends_on_disabled_cells§runtimeÎi®µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9Цqueued¤logs�§running¦output†¤bodyÙ*bernoulli (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚɇi°persist_js_state·has_pluto_hook_features§cell_idÙ$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9¹depends_on_disabled_cells§runtimeÎÛõµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9635c944-0403-11eb-3982-4df509f6a556Цqueued¤logs�§running¦output†¤bodyÚ

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄv…ì°persist_js_state·has_pluto_hook_features§cell_idÙ$9635c944-0403-11eb-3982-4df509f6a556¹depends_on_disabled_cells§runtimeÎf?µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$f3f81172-041c-11eb-2b9b-e99b7b9400edЦqueued¤logs�§running¦output†¤bodyÚ

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!

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄqv´°persist_js_state·has_pluto_hook_features§cell_idÙ$f3f81172-041c-11eb-2b9b-e99b7b9400ed¹depends_on_disabled_cells§runtimeΑ9µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4ad11052-042c-11eb-3643-8b2b3e1269bcЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄv™°persist_js_state·has_pluto_hook_features§cell_idÙ$4ad11052-042c-11eb-3643-8b2b3e1269bc¹depends_on_disabled_cells§runtimeÎ!µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$76d117d4-0403-11eb-05d2-c5ea47d06f43Цqueued¤logs�§running¦output†¤bodyÙ—

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄp™F°persist_js_state·has_pluto_hook_features§cell_idÙ$76d117d4-0403-11eb-05d2-c5ea47d06f43¹depends_on_disabled_cells§runtimeÎpµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$095cbf46-0403-11eb-0c37-35de9562cebcЦqueued¤logs�§running¦output†¤bodyƒ¨elements’’¤name’«"Jazzy Doe"ªtext/plain’«kerberos_id’¦"jazz"ªtext/plain¤typeªNamedTuple¨objectid°eb71b675ed8a366b¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee§student²last_run_timestampËAÚÉ@¯-°persist_js_state·has_pluto_hook_features§cell_idÙ$095cbf46-0403-11eb-0c37-35de9562cebc¹depends_on_disabled_cells§runtimeÍOµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$26e2978e-0435-11eb-0d61-25f552d2771eЦqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄvlr°persist_js_state·has_pluto_hook_features§cell_idÙ$26e2978e-0435-11eb-0d61-25f552d2771e¹depends_on_disabled_cells§runtimeÎ)µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$6de37d6c-0415-11eb-1b05-85ac820016c7Цqueued¤logs�§running¦output†¤bodyÙ^

👉 What happens for $p=1$?

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄpËC°persist_js_state·has_pluto_hook_features§cell_idÙ$6de37d6c-0415-11eb-1b05-85ac820016c7¹depends_on_disabled_cells§runtimeÎßzµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$18d308c4-0424-11eb-176d-49feec6889cfЦqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassigneeªtest_agent²last_run_timestampËAÚÊ{Ý”°persist_js_state·has_pluto_hook_features§cell_idÙ$18d308c4-0424-11eb-176d-49feec6889cf¹depends_on_disabled_cells§runtimeÍ.ϵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$46133a74-04b1-11eb-0b46-0bc74e564680Цqueued¤logs�§running¦output†¤bodyÙ'sweep! (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊäö�°persist_js_state·has_pluto_hook_features§cell_idÙ$46133a74-04b1-11eb-0b46-0bc74e564680¹depends_on_disabled_cells§runtimeÎÞ µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$771c8f0c-0403-11eb-097e-ab24d0714ad5Цqueued¤logs�§running¦output†¤bodyÚ@

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$.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄq°persist_js_state·has_pluto_hook_features§cell_idÙ$771c8f0c-0403-11eb-097e-ab24d0714ad5¹depends_on_disabled_cells§runtimeοRµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$80c2cd88-04b1-11eb-326e-0120a39405eaЦqueued¤logs�§running¦output†¤body…¦prefixÙ:NamedTuple{(:S, :I, :R), Tuple{Missing, Missing, Missing}}¨elementsÜ’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’ ’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’ ’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’ ’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’ ’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’ ’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object’’ƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2Ù!application/vnd.pluto.tree+object¤type¥Array¬prefix_short ¨objectid°cf2b1d28459da63f¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee«simulations²last_run_timestampËAÚË`å2°persist_js_state·has_pluto_hook_features§cell_idÙ$80c2cd88-04b1-11eb-326e-0120a39405ea¹depends_on_disabled_cells§runtimeÍCûµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$105d347e-041c-11eb-2fc8-1d9e5eda2be0Цqueued¤logs�§running¦output†¤bodyÙ,frequencies (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚɼμ°persist_js_state·has_pluto_hook_features§cell_idÙ$105d347e-041c-11eb-2fc8-1d9e5eda2be0¹depends_on_disabled_cells§runtimeÎ_Oµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2c62b4ae-04b3-11eb-0080-a1035a7e31a2Цqueued¤logs�§running¦output†¤bodyƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÚËȨ°persist_js_state·has_pluto_hook_features§cell_idÙ$2c62b4ae-04b3-11eb-0080-a1035a7e31a2¹depends_on_disabled_cells§runtimeÍ�޵published_object_keys�¸depends_on_skipped_cells§erroredÂÙ$6db6c894-0415-11eb-305a-c75b119d89e9Цqueued¤logs�§running¦output†¤bodyÚß

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄp³–°persist_js_state·has_pluto_hook_features§cell_idÙ$6db6c894-0415-11eb-305a-c75b119d89e9¹depends_on_disabled_cells§runtimeÎq˵published_object_keys�¸depends_on_skipped_cells§erroredÂÙ$77db111e-0403-11eb-2dea-4b42ceed65d6Цqueued¤logs�§running¦output†¤bodyÚl

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄr)=°persist_js_state·has_pluto_hook_features§cell_idÙ$77db111e-0403-11eb-2dea-4b42ceed65d6¹depends_on_disabled_cells§runtimeÎù$µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3d88c056-0414-11eb-0025-05d3aff1588bЦqueued¤logs�§running¦output†¤bodyÙ)correct (generic function with 2 methods)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌ@t%°persist_js_state·has_pluto_hook_features§cell_idÙ$3d88c056-0414-11eb-0025-05d3aff1588b¹depends_on_disabled_cells§runtimeÎ ¬µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$287ee7aa-0435-11eb-0ca3-951dbbe69404Цqueued¤logs�§running¦output†¤bodyÙ4sir_mean_error_plot (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚË÷kð°persist_js_state·has_pluto_hook_features§cell_idÙ$287ee7aa-0435-11eb-0ca3-951dbbe69404¹depends_on_disabled_cells§runtimeÎ Mĵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$03a85970-0403-11eb-334a-812b59c0905bЦqueued¤logs�§running¦output†¤bodyÙm

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÉy0 °persist_js_state·has_pluto_hook_features§cell_idÙ$03a85970-0403-11eb-334a-812b59c0905b¹depends_on_disabled_cells§runtimeÎ%Áµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$6d906d0c-0415-11eb-0c1c-b5c0aca841dbЦqueued¤logs�§running¦output†¤bodyÙé

Hint

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌ °persist_js_state·has_pluto_hook_features§cell_idÙ$6d906d0c-0415-11eb-0c1c-b5c0aca841db¹depends_on_disabled_cells§runtime΃‹/µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$866299e8-0403-11eb-085d-2b93459cc141Цqueued¤logs�§running¦output†¤bodyÙ¸

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄsvl°persist_js_state·has_pluto_hook_features§cell_idÙ$866299e8-0403-11eb-085d-2b93459cc141¹depends_on_disabled_cells§runtimeεpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$461586dc-0414-11eb-00f3-4984b57bfac5Цqueued¤logs�§running¦output†¤bodyÙ'almost (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌNU°persist_js_state·has_pluto_hook_features§cell_idÙ$461586dc-0414-11eb-00f3-4984b57bfac5¹depends_on_disabled_cells§runtimeÎεpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c5156c72-04af-11eb-1106-b13969b036caЦqueued¤logs�§running¦output†¤body‚£msgÙ2Cannot convert Missing to series data for plottingªstacktracešŒªcall_short°error(s::String)§inlined£urlÙbhttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/error.jl#L33¤pathª./error.jl®source_packageÀ¤call°error(s::String)ªlinfo_type³Core.MethodInstance¤line!¤file¨error.jl¤func¥error­parent_moduleÀ¦from_cÂŒªcall_shortÙ _prepare_series_data(x::Missing)§inlined£urlÙGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤callÙ _prepare_series_data(x::Missing)ªlinfo_type³Core.MethodInstance¤line¤file©series.jl¤func´_prepare_series_data­parent_moduleÀ¦from_cÂŒªcall_shortÙB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})§inlined£urlÙGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤callÙB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})ªlinfo_type³Core.MethodInstance¤line$¤file©series.jl¤func³_series_data_vector­parent_moduleÀ¦from_cÂŒªcall_short¯macro expansion§inlinedãurlÀ¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤call¯macro expansionªlinfo_type§Nothing¤lineÌ�¤file©series.jl¤func¯macro expansion­parent_moduleÀ¦from_cÂŒªcall_shortÙxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)§inlined£urlÙHfile:///home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl¤pathÙA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl®source_packageÀ¤callÙxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)ªlinfo_type³Core.MethodInstance¤lineÍ,¤file®RecipesBase.jl¤func¬apply_recipe­parent_moduleÀ¦from_cÂŒªcall_shortÙ?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)§inlined£urlÙLfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl¤pathÙE/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl®source_packageÀ¤callÙ?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤line&¤file®user_recipe.jl¤funcµ_process_userrecipes!­parent_moduleÀ¦from_cÂŒªcall_shortÙ:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)§inlined£urlÙPfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl¤pathÙI/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl®source_packageÀ¤callÙ:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤lineH¤file²RecipesPipeline.jl¤func°recipe_pipeline!­parent_moduleÀ¦from_cÂŒªcall_shortÙ7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)§inlined£urlÙ;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jl¤pathÙ4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jl®source_packageÀ¤callÙ7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤lineÌߤfile§plot.jl¤func¦_plot!­parent_moduleÀ¦from_cÂŒªcall_short©#plot#186§inlinedãurlÀ¤pathÙ4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jl®source_packageÀ¤call©#plot#186ªlinfo_type§Nothing¤linef¤file§plot.jl¤func©#plot#186­parent_moduleÀ¦from_cÂŒªcall_short¯top-level scope§inlinedãurlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#c5156c72-04af-11eb-1106-b13969b036ca®source_packageÀ¤call¯top-level scopeªlinfo_type§Nothing¤line¤fileÙ.hw4.jl#==#c5156c72-04af-11eb-1106-b13969b036ca¤func»##function_wrapped_cell#396­parent_moduleÀ¦from_c¤mimeÙ'application/vnd.pluto.stacktrace+object¬rootassigneeÀ²last_run_timestampËAÚË9¥°persist_js_state·has_pluto_hook_features§cell_idÙ$c5156c72-04af-11eb-1106-b13969b036ca¹depends_on_disabled_cells§runtimeÀµpublished_object_keys�¸depends_on_skipped_cells§erroredÃÙ$c4a8694a-04d4-11eb-1eef-c9e037e6b21fЦqueued¤logs�§running¦output†¤bodyÙ¥

Here we go!

Replace missing with your answer.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌWÇó°persist_js_state·has_pluto_hook_features§cell_idÙ$c4a8694a-04d4-11eb-1eef-c9e037e6b21f¹depends_on_disabled_cells§runtimeÎ µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1491a078-04aa-11eb-0106-19a3cf1e94b0Цqueued¤logs�§running¦output†¤bodyÙØ

Keep working on it!

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌeȽ°persist_js_state·has_pluto_hook_features§cell_idÙ$1491a078-04aa-11eb-0106-19a3cf1e94b0¹depends_on_disabled_cells§runtimeÎhàµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$c5c7cb86-041b-11eb-3360-45463105f3c9Цqueued¤logs�§running¦output†¤bodyÙ.do_experiment (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚɤý—°persist_js_state·has_pluto_hook_features§cell_idÙ$c5c7cb86-041b-11eb-3360-45463105f3c9¹depends_on_disabled_cells§runtimeÎ,�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$01341648-0403-11eb-2212-db450c299f35Цqueued¤logs�§running¦output†¤bodyÙB

homework 4, version 1

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄp=°persist_js_state·has_pluto_hook_features§cell_idÙ$01341648-0403-11eb-2212-db450c299f35¹depends_on_disabled_cells§runtimeÎ@ˆµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$48a16c42-0414-11eb-0e0c-bf52bbb0f618Цqueued¤logs�§running¦output†¤bodyÙ%hint (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌ:°persist_js_state·has_pluto_hook_features§cell_idÙ$48a16c42-0414-11eb-0e0c-bf52bbb0f618¹depends_on_disabled_cells§runtimeÎs¶µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$98beb336-0425-11eb-3886-4f8cfd210288Цqueued¤logs�§running¦output†¤bodyÙ,set_status! (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊŒkô°persist_js_state·has_pluto_hook_features§cell_idÙ$98beb336-0425-11eb-3886-4f8cfd210288¹depends_on_disabled_cells§runtimeÎÄ�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$bb63f3cc-042f-11eb-04ff-a128aec3c378Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄqʧ°persist_js_state·has_pluto_hook_features§cell_idÙ$bb63f3cc-042f-11eb-04ff-a128aec3c378¹depends_on_disabled_cells§runtimeÎYµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$61c00724-0403-11eb-228d-17c11670e5d1Цqueued¤logs�§running¦output†¤bodyÚ™

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄv¼V°persist_js_state·has_pluto_hook_features§cell_idÙ$61c00724-0403-11eb-228d-17c11670e5d1¹depends_on_disabled_cells§runtimeÎ �Gµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9cf9080a-04b1-11eb-12a0-17013f2d37f5Цqueued¤logs�§running¦output†¤bodyÚ,

👉 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!

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌ Ç¬°persist_js_state·has_pluto_hook_features§cell_idÙ$9cf9080a-04b1-11eb-12a0-17013f2d37f5¹depends_on_disabled_cells§runtimeÎg;µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassignee°large_experiment²last_run_timestampËAÚɾÊK°persist_js_state·has_pluto_hook_features§cell_idÙ$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8¹depends_on_disabled_cells§runtimeÍ6ʵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$61789646-0403-11eb-0042-f3b8308f11baЦqueued¤logs�§running¦output†¤bodyÚ3

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:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄrfI°persist_js_state·has_pluto_hook_features§cell_idÙ$61789646-0403-11eb-0042-f3b8308f11ba¹depends_on_disabled_cells§runtimeÎ ­ìµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$39dffa3c-0414-11eb-0197-e72b299e9c63Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌnBÕ°persist_js_state·has_pluto_hook_features§cell_idÙ$39dffa3c-0414-11eb-0197-e72b299e9c63¹depends_on_disabled_cells§runtimeÍ‚­µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272Цqueued¤logs�§running¦output†¤bodyÙÀ

Got it!

Your function treats the recovered agent case correctly!

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌiÌѰpersist_js_state·has_pluto_hook_features§cell_idÙ$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272¹depends_on_disabled_cells§runtimeΊHµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$88c53208-041d-11eb-3b1e-31b57ba99f05Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄr«C°persist_js_state·has_pluto_hook_features§cell_idÙ$88c53208-041d-11eb-3b1e-31b57ba99f05¹depends_on_disabled_cells§runtimeμµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$887d27fc-04bc-11eb-0ab9-eb95ef9607f8Цqueued¤logs�§running¦output†¤bodyÙ+simulation (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊïÁß°persist_js_state·has_pluto_hook_features§cell_idÙ$887d27fc-04bc-11eb-0ab9-eb95ef9607f8¹depends_on_disabled_cells§runtimeÎz|µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$d57c6a5a-041b-11eb-3ab4-774a2d45a891Цqueued¤logs�§running¦output†¤bodyÙ.recovery_time (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÉ“*x°persist_js_state·has_pluto_hook_features§cell_idÙ$d57c6a5a-041b-11eb-3ab4-774a2d45a891¹depends_on_disabled_cells§runtimeÎöµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$12cc2940-0403-11eb-19a7-bb570de58f6fЦqueued¤logs‘ˆ¤lineÿ£msg’Ù@ Activating new project at `/tmp/jl_tSReBH` ªtext/plain§cell_idÙ$12cc2940-0403-11eb-19a7-bb570de58f6f¦kwargs�¢id´PlutoRunner_d1acb81e¤fileÙP/home/runner/.julia/packages/Pluto/6smog/src/runner/PlutoRunner/src/io/stdout.jl¥group¦stdout¥level®LogLevel(-555)§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÆŸÁ­°persist_js_state·has_pluto_hook_features§cell_idÙ$12cc2940-0403-11eb-19a7-bb570de58f6f¹depends_on_disabled_cells§runtimeÎYHßµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$76f62d64-0403-11eb-27e2-3de58366b619Цqueued¤logs�§running¦output†¤bodyÙç

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄpä2°persist_js_state·has_pluto_hook_features§cell_idÙ$76f62d64-0403-11eb-27e2-3de58366b619¹depends_on_disabled_cells§runtimeÎÒçµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$860790fc-0403-11eb-2f2e-355f77dcc7afЦqueued¤logs�§running¦output†¤bodyÚL

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:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄrÞ¹°persist_js_state·has_pluto_hook_features§cell_idÙ$860790fc-0403-11eb-2f2e-355f77dcc7af¹depends_on_disabled_cells§runtimeΜµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b21475c6-04ac-11eb-1366-f3b5e967402dЦqueued¤logs�§running¦output†¤bodyÚ

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄsç°persist_js_state·has_pluto_hook_features§cell_idÙ$b21475c6-04ac-11eb-1366-f3b5e967402d¹depends_on_disabled_cells§runtimeÎQ£µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$823364ce-041c-11eb-2467-7ffa4f751527Цqueued¤logs�§running¦output†¤bodyÙ>frequencies_plot_with_maximum (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ@þ¬°persist_js_state·has_pluto_hook_features§cell_idÙ$823364ce-041c-11eb-2467-7ffa4f751527¹depends_on_disabled_cells§runtimeÎ 1µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$619c8a10-0403-11eb-2e89-8b0974fb01d0Цqueued¤logs�§running¦output†¤bodyÚÛ

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:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄt´°persist_js_state·has_pluto_hook_features§cell_idÙ$619c8a10-0403-11eb-2e89-8b0974fb01d0¹depends_on_disabled_cells§runtimeÎV•µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076Цqueued¤logs�§running¦output†¤bodyÙ3repeat_simulations (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚËBèÕ°persist_js_state·has_pluto_hook_features§cell_idÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076¹depends_on_disabled_cells§runtimeÎm&µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$8dd97820-04a5-11eb-36c0-8f92d4b859a8Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄvÏÀ°persist_js_state·has_pluto_hook_features§cell_idÙ$8dd97820-04a5-11eb-36c0-8f92d4b859a8¹depends_on_disabled_cells§runtimeΦµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$df8547b4-0400-11eb-07c6-fb370b61c2b6Цqueued¤logs�§running¦output†¤bodyÚP

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)$.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄp€Ç°persist_js_state·has_pluto_hook_features§cell_idÙ$df8547b4-0400-11eb-07c6-fb370b61c2b6¹depends_on_disabled_cells§runtimeÎÞ&µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1d3356c4-0403-11eb-0f48-01b5eb14a585Цqueued¤logs�§running¦output†¤bodyÙÔ ¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄp^ú°persist_js_state·has_pluto_hook_features§cell_idÙ$1d3356c4-0403-11eb-0f48-01b5eb14a585¹depends_on_disabled_cells§runtimeÎÚêµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$82f2580a-04c8-11eb-1eea-bdb4e50eee3bЦqueued¤logs�§running¦output†¤body‚£msgÚ¯MethodError: 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:2ªstacktrace‘Œªcall_short¯top-level scope§inlinedãurlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#82f2580a-04c8-11eb-1eea-bdb4e50eee3b®source_packageÀ¤call¯top-level scopeªlinfo_type§Nothing¤line¤fileÙ.hw4.jl#==#82f2580a-04c8-11eb-1eea-bdb4e50eee3b¤func»##function_wrapped_cell#354­parent_moduleÀ¦from_c¤mimeÙ'application/vnd.pluto.stacktrace+object¬rootassigneeÀ²last_run_timestampËAÚÊ�êÀ°persist_js_state·has_pluto_hook_features§cell_idÙ$82f2580a-04c8-11eb-1eea-bdb4e50eee3b¹depends_on_disabled_cells§runtimeÀµpublished_object_keys�¸depends_on_skipped_cells§erroredÃÙ$86d98d0a-0403-11eb-215b-c58ad721a90bЦqueued¤logs�§running¦output†¤bodyÚ�

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄsª‚°persist_js_state·has_pluto_hook_features§cell_idÙ$86d98d0a-0403-11eb-215b-c58ad721a90b¹depends_on_disabled_cells§runtimeÎ)Gµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$dc784864-0430-11eb-1478-d1153e017310Цqueued¤logs�§running¦output†¤bodyÚ‡

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:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄq6¨°persist_js_state·has_pluto_hook_features§cell_idÙ$dc784864-0430-11eb-1478-d1153e017310¹depends_on_disabled_cells§runtimeΠSµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3f5e0af8-0414-11eb-34a7-a71e7aaf6443Цqueued¤logs�§running¦output†¤body…¦prefix«Markdown.MD¨elements›’’Ù2

Fantastic!

©text/html’’Ù1

Splendid!

©text/html’’Ù.

Great!

©text/html’’Ù+

Yay �

©text/html’’Ù3

Great! 🎉

©text/html’’Ù2

Well done!

©text/html’’Ù3

Keep it up!

©text/html’’Ù1

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/html¤type¥Array¬prefix_short ¨objectid°7e19e2361e36a1ab¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee¤yays²last_run_timestampËAÚÌ5¯’°persist_js_state·has_pluto_hook_features§cell_idÙ$3f5e0af8-0414-11eb-34a7-a71e7aaf6443¹depends_on_disabled_cells§runtimeΣA#µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$3c0528a0-0414-11eb-2f68-a5657ab9e73dЦqueued¤logs�§running¦output†¤bodyÙ,not_defined (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌK

Here we go!

Replace missing with your answer.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌU™°persist_js_state·has_pluto_hook_features§cell_idÙ$c61f35ea-04d6-11eb-2503-17a79f8d0298¹depends_on_disabled_cells§runtimeÎUÄAµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9cd2bb00-04b1-11eb-1d83-a703907141a7Цqueued¤logs�§running¦output†¤body‚£msgÙ2Cannot convert Missing to series data for plottingªstacktracešŒªcall_short°error(s::String)§inlined£urlÙbhttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/error.jl#L33¤pathª./error.jl®source_packageÀ¤call°error(s::String)ªlinfo_type³Core.MethodInstance¤line!¤file¨error.jl¤func¥error­parent_moduleÀ¦from_cÂŒªcall_shortÙ _prepare_series_data(x::Missing)§inlined£urlÙGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤callÙ _prepare_series_data(x::Missing)ªlinfo_type³Core.MethodInstance¤line¤file©series.jl¤func´_prepare_series_data­parent_moduleÀ¦from_cÂŒªcall_shortÙB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})§inlined£urlÙGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤callÙB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})ªlinfo_type³Core.MethodInstance¤line$¤file©series.jl¤func³_series_data_vector­parent_moduleÀ¦from_cÂŒªcall_short¯macro expansion§inlinedãurlÀ¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤call¯macro expansionªlinfo_type§Nothing¤lineÌ�¤file©series.jl¤func¯macro expansion­parent_moduleÀ¦from_cÂŒªcall_shortÙxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)§inlined£urlÙHfile:///home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl¤pathÙA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl®source_packageÀ¤callÙxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)ªlinfo_type³Core.MethodInstance¤lineÍ,¤file®RecipesBase.jl¤func¬apply_recipe­parent_moduleÀ¦from_cÂŒªcall_shortÙ?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)§inlined£urlÙLfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl¤pathÙE/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl®source_packageÀ¤callÙ?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤line&¤file®user_recipe.jl¤funcµ_process_userrecipes!­parent_moduleÀ¦from_cÂŒªcall_shortÙ:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)§inlined£urlÙPfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl¤pathÙI/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl®source_packageÀ¤callÙ:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤lineH¤file²RecipesPipeline.jl¤func°recipe_pipeline!­parent_moduleÀ¦from_cÂŒªcall_shortÙ7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)§inlined£urlÙ;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jl¤pathÙ4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jl®source_packageÀ¤callÙ7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤lineÌߤfile§plot.jl¤func¦_plot!­parent_moduleÀ¦from_cÂŒªcall_shortª#plot!#197§inlinedãurlÀ¤pathÙ4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jl®source_packageÀ¤callª#plot!#197ªlinfo_type§Nothing¤lineÌÕ¤file§plot.jl¤funcª#plot!#197­parent_moduleÀ¦from_cÂŒªcall_short¯top-level scope§inlinedãurlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#9cd2bb00-04b1-11eb-1d83-a703907141a7®source_packageÀ¤call¯top-level scopeªlinfo_type§Nothing¤line¤fileÙ.hw4.jl#==#9cd2bb00-04b1-11eb-1d83-a703907141a7¤func»##function_wrapped_cell#406­parent_moduleÀ¦from_c¤mimeÙ'application/vnd.pluto.stacktrace+object¬rootassigneeÀ²last_run_timestampËAÚËÔÚ”°persist_js_state·has_pluto_hook_features§cell_idÙ$9cd2bb00-04b1-11eb-1d83-a703907141a7¹depends_on_disabled_cells§runtimeÀµpublished_object_keys�¸depends_on_skipped_cells§erroredÃÙ$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bЦqueued¤logs�§running¦output†¤body‚£msgÙ2Cannot convert Missing to series data for plottingªstacktraceœŒªcall_short°error(s::String)§inlined£urlÙbhttps://github.com/JuliaLang/julia/tree/742b9abb4dd4621b667ec5bb3434b8b3602f96fd/base/error.jl#L33¤pathª./error.jl®source_packageÀ¤call°error(s::String)ªlinfo_type³Core.MethodInstance¤line!¤file¨error.jl¤func¥error­parent_moduleÀ¦from_cÂŒªcall_shortÙ _prepare_series_data(x::Missing)§inlined£urlÙGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤callÙ _prepare_series_data(x::Missing)ªlinfo_type³Core.MethodInstance¤line¤file©series.jl¤func´_prepare_series_data­parent_moduleÀ¦from_cÂŒªcall_shortÙB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})§inlined£urlÙGfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤callÙB_series_data_vector(x::Missing, plotattributes::Dict{Symbol, Any})ªlinfo_type³Core.MethodInstance¤line$¤file©series.jl¤func³_series_data_vector­parent_moduleÀ¦from_cÂŒªcall_short¯macro expansion§inlinedãurlÀ¤pathÙ@/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/series.jl®source_packageÀ¤call¯macro expansionªlinfo_type§Nothing¤lineÌ�¤file©series.jl¤func¯macro expansion­parent_moduleÀ¦from_cÂŒªcall_shortÙxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)§inlined£urlÙHfile:///home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl¤pathÙA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl®source_packageÀ¤callÙxapply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)ªlinfo_type³Core.MethodInstance¤lineÍ,¤file®RecipesBase.jl¤func¬apply_recipe­parent_moduleÀ¦from_cÂŒªcall_shortÙ?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)§inlined£urlÙLfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl¤pathÙE/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/user_recipe.jl®source_packageÀ¤callÙ?_process_userrecipes!(plt::Any, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤line&¤file®user_recipe.jl¤funcµ_process_userrecipes!­parent_moduleÀ¦from_cÂŒªcall_shortÙ:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)§inlined£urlÙPfile:///home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl¤pathÙI/home/runner/.julia/packages/RecipesPipeline/BGM3l/src/RecipesPipeline.jl®source_packageÀ¤callÙ:recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤lineH¤file²RecipesPipeline.jl¤func°recipe_pipeline!­parent_moduleÀ¦from_cÂŒªcall_shortÙ7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)§inlined£urlÙ;file:///home/runner/.julia/packages/Plots/uiCPf/src/plot.jl¤pathÙ4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jl®source_packageÀ¤callÙ7_plot!(plt::Plots.Plot, plotattributes::Any, args::Any)ªlinfo_type³Core.MethodInstance¤lineÌߤfile§plot.jl¤func¦_plot!­parent_moduleÀ¦from_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.jl¤pathÙ4/home/runner/.julia/packages/Plots/uiCPf/src/plot.jl®source_packageÀ¤callÙˆ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_type³Core.MethodInstance¤linef¤file§plot.jl¤func©#plot#186­parent_moduleÀ¦from_cÂŒªcall_short¨#bar#365§inlinedãurlÀ¤pathÙA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl®source_packageÀ¤call¨#bar#365ªlinfo_type§Nothing¤lineÍ«¤file®RecipesBase.jl¤func¨#bar#365­parent_moduleÀ¦from_cÂŒªcall_short£bar§inlinedãurlÀ¤pathÙA/home/runner/.julia/packages/RecipesBase/BRe07/src/RecipesBase.jl®source_packageÀ¤call£barªlinfo_type§Nothing¤lineÍ«¤file®RecipesBase.jl¤func£bar­parent_moduleÀ¦from_cÂŒªcall_short¯top-level scope§inlinedãurlÀ¤pathÙd/home/runner/work/disorganised-mess/disorganised-mess/hw4.jl#==#8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b®source_packageÀ¤call¯top-level scopeªlinfo_type§Nothing¤line¤fileÙ.hw4.jl#==#8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b¤func»##function_wrapped_cell#326­parent_moduleÀ¦from_c¤mimeÙ'application/vnd.pluto.stacktrace+object¬rootassigneeÀ²last_run_timestampËAÚÊ6&5°persist_js_state·has_pluto_hook_features§cell_idÙ$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b¹depends_on_disabled_cells§runtimeÀµpublished_object_keys�¸depends_on_skipped_cells§erroredÃÙ$8631a536-0403-11eb-0379-bb2e56927727Цqueued¤logs�§running¦output†¤bodyÚ�

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.]

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄs^¦°persist_js_state·has_pluto_hook_features§cell_idÙ$8631a536-0403-11eb-0379-bb2e56927727¹depends_on_disabled_cells§runtimeεµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9a13b17c-0403-11eb-024f-9b37e95e211bЦqueued¤logs�§running¦output†¤bodyÚ

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.)

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄw[°persist_js_state·has_pluto_hook_features§cell_idÙ$9a13b17c-0403-11eb-024f-9b37e95e211b¹depends_on_disabled_cells§runtimeÎTȵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$b92f1cec-04ae-11eb-0072-3535d1118494Цqueued¤logs�§running¦output†¤bodyƒ¨elements“’¡S’§missingªtext/plain’¡I’§missingªtext/plain’¡R’§missingªtext/plain¤typeªNamedTuple¨objectid°ffffffff7c5378c2¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÚËTó°persist_js_state·has_pluto_hook_features§cell_idÙ$b92f1cec-04ae-11eb-0072-3535d1118494¹depends_on_disabled_cells§runtimeÍ:Óµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9a377b32-0403-11eb-2799-e7e59caa6a45Цqueued¤logs�§running¦output†¤bodyÙæ

👉 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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄw2Y°persist_js_state·has_pluto_hook_features§cell_idÙ$9a377b32-0403-11eb-2799-e7e59caa6a45¹depends_on_disabled_cells§runtimeεpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$778ec25c-0403-11eb-3146-1d11c294bb1fЦqueued¤logs�§running¦output†¤bodyÙ²

Exercise 1.5

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄqü¤°persist_js_state·has_pluto_hook_features§cell_idÙ$778ec25c-0403-11eb-3146-1d11c294bb1f¹depends_on_disabled_cells§runtimeÎvmµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9611ca24-0403-11eb-3582-b7e3bb243e62Цqueued¤logs�§running¦output†¤bodyÙù

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.)

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄvY>°persist_js_state·has_pluto_hook_features§cell_idÙ$9611ca24-0403-11eb-3582-b7e3bb243e62¹depends_on_disabled_cells§runtimeÎÖ½µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$26f84600-041d-11eb-1856-b12a3e5c1dc7Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊres°persist_js_state·has_pluto_hook_features§cell_idÙ$26f84600-041d-11eb-1856-b12a3e5c1dc7¹depends_on_disabled_cells§runtimeÎW8~µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1ca7a8c2-041a-11eb-146a-15b8cdeaea72Цqueued¤logs�§running¦output†¤body§missing¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚɾr“°persist_js_state·has_pluto_hook_features§cell_idÙ$1ca7a8c2-041a-11eb-146a-15b8cdeaea72¹depends_on_disabled_cells§runtimeÍ-3µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$190deebc-0424-11eb-19fe-615997093e14Цqueued¤logs�§running¦output†¤bodyÚÈ

👉 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?

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄsC‘°persist_js_state·has_pluto_hook_features§cell_idÙ$190deebc-0424-11eb-19fe-615997093e14¹depends_on_disabled_cells§runtimeÎ/µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1a654bdc-0421-11eb-2c38-7d35060e2565Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ­ºØ°persist_js_state·has_pluto_hook_features§cell_idÙ$1a654bdc-0421-11eb-2c38-7d35060e2565¹depends_on_disabled_cells§runtimeÎ zJµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$41cefa68-0414-11eb-3bad-6530360d6f68Цqueued¤logs�§running¦output†¤bodyÙ.keep_working (generic function with 2 methods)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌ(Ö¶°persist_js_state·has_pluto_hook_features§cell_idÙ$41cefa68-0414-11eb-3bad-6530360d6f68¹depends_on_disabled_cells§runtimeÎ gµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$847d0fc2-041d-11eb-2864-79066e223b45Цqueued¤logs�§running¦output†¤bodyÙÆ

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄrÃ�°persist_js_state·has_pluto_hook_features§cell_idÙ$847d0fc2-041d-11eb-2864-79066e223b45¹depends_on_disabled_cells§runtimeÎNÒµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$77428072-0403-11eb-0068-81e3728f2ebeЦqueued¤logs�§running¦output†¤bodyÙ—

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

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄq°persist_js_state·has_pluto_hook_features§cell_idÙ$77428072-0403-11eb-0068-81e3728f2ebe¹depends_on_disabled_cells§runtimeÎ ѵpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$9a837b52-0425-11eb-231f-a74405ff6e23Цqueued¤logs�§running¦output†¤bodyÙ/is_susceptible (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ–13°persist_js_state·has_pluto_hook_features§cell_idÙ$9a837b52-0425-11eb-231f-a74405ff6e23¹depends_on_disabled_cells§runtimeÎjlµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$0a967f38-0493-11eb-0624-77e40b24d757Цqueued¤logs�§running¦output†¤bodyÚ ß

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!

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄu£°persist_js_state·has_pluto_hook_features§cell_idÙ$0a967f38-0493-11eb-0624-77e40b24d757¹depends_on_disabled_cells§runtimeÎ t�µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$28db9d98-04ca-11eb-3606-9fb89fa62f36Цqueued¤logs�§running¦output†¤bodyÙm¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚË)ž°persist_js_state·has_pluto_hook_features§cell_idÙ$28db9d98-04ca-11eb-3606-9fb89fa62f36¹depends_on_disabled_cells§runtimeÎ —½µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$8692bf42-0403-11eb-191f-b7d08895274fЦqueued¤logs�§running¦output†¤bodyÚ8

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄs�°°persist_js_state·has_pluto_hook_features§cell_idÙ$8692bf42-0403-11eb-191f-b7d08895274f¹depends_on_disabled_cells§runtimeζµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$da49710e-0420-11eb-092e-4f1173868738Цqueued¤logs�§running¦output†¤bodyÚé

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:

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄwaž°persist_js_state·has_pluto_hook_features§cell_idÙ$da49710e-0420-11eb-092e-4f1173868738¹depends_on_disabled_cells§runtimeγtµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$7bb8e426-0495-11eb-3a8b-cbbab61a1631Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄr,°persist_js_state·has_pluto_hook_features§cell_idÙ$7bb8e426-0495-11eb-3a8b-cbbab61a1631¹depends_on_disabled_cells§runtimeεpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$21c50840-0435-11eb-1307-7138ecde0691Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄwEA°persist_js_state·has_pluto_hook_features§cell_idÙ$21c50840-0435-11eb-1307-7138ecde0691¹depends_on_disabled_cells§runtimeÎKµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2ade2694-0425-11eb-2fb2-390da43d9695Цqueued¤logs�§running¦output†¤bodyÙ&step! (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊÚA)°persist_js_state·has_pluto_hook_features§cell_idÙ$2ade2694-0425-11eb-2fb2-390da43d9695¹depends_on_disabled_cells§runtimeÎØŽµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$bf6fd176-04cc-11eb-008a-2fb6ff70a9cbЦqueued¤logs�§running¦output†¤bodyÚ

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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄuÆ‚°persist_js_state·has_pluto_hook_features§cell_idÙ$bf6fd176-04cc-11eb-008a-2fb6ff70a9cb¹depends_on_disabled_cells§runtimeÎùµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$73047bba-0416-11eb-1047-23e9c3dbde05Цqueued¤logs�§running¦output†¤bodyÙ-

blablabla

¤mime©text/html¬rootassignee¾interpretation_of_p_equals_one²last_run_timestampËAÚÉ“f°persist_js_state·has_pluto_hook_features§cell_idÙ$73047bba-0416-11eb-1047-23e9c3dbde05¹depends_on_disabled_cells§runtimeÎÕµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$43e6e856-0414-11eb-19ca-07358aa8b667Цqueued¤logs�§running¦output†¤bodyÙ/still_missing (generic function with 2 methods)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÌ冰persist_js_state·has_pluto_hook_features§cell_idÙ$43e6e856-0414-11eb-19ca-07358aa8b667¹depends_on_disabled_cells§runtimeÎ ‘ªµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$2b26dc42-0403-11eb-205f-cd2c23d8cb03Цqueued¤logs�§running¦output†¤body´




¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÌwšJ°persist_js_state·has_pluto_hook_features§cell_idÙ$2b26dc42-0403-11eb-205f-cd2c23d8cb03¹depends_on_disabled_cells§runtimeÍ%‘µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$95c598d4-0403-11eb-2328-0175ed564915Цqueued¤logs�§running¦output†¤bodyÙý

👉 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.

¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÄu÷˰persist_js_state·has_pluto_hook_features§cell_idÙ$95c598d4-0403-11eb-2328-0175ed564915¹depends_on_disabled_cells§runtimeÎ}‚µpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$1ac4b33a-0435-11eb-36f8-8f3f81ae7844Цqueued¤logs�§running¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÄw½°persist_js_state·has_pluto_hook_features§cell_idÙ$1ac4b33a-0435-11eb-36f8-8f3f81ae7844¹depends_on_disabled_cells§runtimeΪµpublished_object_keys�¸depends_on_skipped_cells§erroredÂÙ$a8dd5cae-0425-11eb-119c-bfcbf832d695Цqueued¤logs�§running¦output†¤bodyÙ,is_infected (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÊ ¨e°persist_js_state·has_pluto_hook_features§cell_idÙ$a8dd5cae-0425-11eb-119c-bfcbf832d695¹depends_on_disabled_cells§runtimeÎxyµpublished_object_keys�¸depends_on_skipped_cells§errored±cell_dependenciesÞ€Ù$f1f89502-0494-11eb-2303-0b79d8bbd13f„´precedence_heuristic §cell_idÙ$f1f89502-0494-11eb-2303-0b79d8bbd13f´downstream_cells_map�ºfrequencies_plot_with_mean‘Ù$06089d1e-0495-11eb-0ace-a7a7dc60e5b2²upstream_cells_map�§missing�Ù$95771ce2-0403-11eb-3056-f1dc3a8b7ec3„´precedence_heuristic §cell_idÙ$95771ce2-0403-11eb-3056-f1dc3a8b7ec3´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$e6219c7c-0420-11eb-3faa-13126f7c8007„´precedence_heuristic §cell_idÙ$e6219c7c-0420-11eb-3faa-13126f7c8007´downstream_cells_map�®lines_i_edited�²upstream_cells_map‚§@md_str�¨getindex�Ù$b817f466-04d4-11eb-0a26-c1c667f9f7f7„´precedence_heuristic §cell_idÙ$b817f466-04d4-11eb-0a26-c1c667f9f7f7´downstream_cells_map€²upstream_cells_mapާ@md_str�­Base.getindex�§Missing�¡!�ª@isdefined�¤Bool�­still_missing‘Ù$43e6e856-0414-11eb-19ca-07358aa8b667£isa�¤Base�§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d¢==�©bernoulli‘Ù$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9Ù$08e2bc64-0417-11eb-1457-21c0d18e8c51„´precedence_heuristic §cell_idÙ$08e2bc64-0417-11eb-1457-21c0d18e8c51´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¤hint‘Ù$48a16c42-0414-11eb-0e0c-bf52bbb0f618¨getindex�Ù$bb8aeb58-042f-11eb-18b8-f995631df619„´precedence_heuristic §cell_idÙ$bb8aeb58-042f-11eb-18b8-f995631df619´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$223933a4-042c-11eb-10d3-852229f25a35„´precedence_heuristic §cell_idÙ$223933a4-042c-11eb-10d3-852229f25a35´downstream_cells_map�±AbstractInfection”Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$2ade2694-0425-11eb-2fb2-390da43d9695Ù$46133a74-04b1-11eb-0b46-0bc74e564680Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8²upstream_cells_map€Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2„´precedence_heuristic §cell_idÙ$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2´downstream_cells_map�¥AgentžÙ$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-0bc74e564680²upstream_cells_map‚¥Int64�¯InfectionStatus‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7Ù$7f635722-04d0-11eb-3209-4b603c9e843c„´precedence_heuristic §cell_idÙ$7f635722-04d0-11eb-3209-4b603c9e843c´downstream_cells_map€²upstream_cells_map‚«simulations‘Ù$80c2cd88-04b1-11eb-326e-0120a39405ea­sir_mean_plot‘Ù$843fd63c-04d0-11eb-0113-c58d346179d6Ù$7c515a7a-04d5-11eb-0f36-4fcebff709d5„´precedence_heuristic §cell_idÙ$7c515a7a-04d5-11eb-0f36-4fcebff709d5´downstream_cells_map€²upstream_cells_mapŠ¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68¡!�«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73dª@isdefined�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2¡R‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¢==�«set_status!‘Ù$98beb336-0425-11eb-3886-4f8cfd210288Ù$107e65a4-0403-11eb-0c14-37d8d828b469„´precedence_heuristic §cell_idÙ$107e65a4-0403-11eb-0c14-37d8d828b469´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0„´precedence_heuristic §cell_idÙ$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0´downstream_cells_map€²upstream_cells_map€Ù$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bb„´precedence_heuristic §cell_idÙ$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bb´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7f4e121c-041d-11eb-0dff-cd0cbfdfd606„´precedence_heuristic §cell_idÙ$7f4e121c-041d-11eb-0dff-cd0cbfdfd606´downstream_cells_map�«test_status�²upstream_cells_map�§missing�Ù$4f19e872-0414-11eb-0dfd-e53d2aecc4dc„´precedence_heuristic §cell_idÙ$4f19e872-0414-11eb-0dfd-e53d2aecc4dc´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$5689841e-0414-11eb-0492-63c77ddbd136„´precedence_heuristic §cell_idÙ$5689841e-0414-11eb-0492-63c77ddbd136´downstream_cells_map€²upstream_cells_map�¨bigbreak‘Ù$39dffa3c-0414-11eb-0197-e72b299e9c63Ù$759bc42e-04ab-11eb-0ab1-b12e008c02a9„´precedence_heuristic §cell_idÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9´downstream_cells_map€²upstream_cells_mapÞ§@md_str�­Base.getindex�¡!�ª@isdefined�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2©interact!‘Ù$406aabea-04a5-11eb-06b8-312879457c42¤Base�¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¡S‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d¢!=�¡R‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¢==�¦almost‘Ù$461586dc-0414-11eb-00f3-4984b57bfac5±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$99ef7b2a-0403-11eb-08ef-e1023cd151ae„´precedence_heuristic §cell_idÙ$99ef7b2a-0403-11eb-08ef-e1023cd151ae´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$77b54c10-0403-11eb-16ad-65374d29a817„´precedence_heuristic §cell_idÙ$77b54c10-0403-11eb-16ad-65374d29a817´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7768a2dc-0403-11eb-39b7-fd660dc952fe„´precedence_heuristic §cell_idÙ$7768a2dc-0403-11eb-39b7-fd660dc952fe´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$60a8b708-04c8-11eb-37b1-3daec644ac90„´precedence_heuristic §cell_idÙ$60a8b708-04c8-11eb-37b1-3daec644ac90´downstream_cells_map€²upstream_cells_map€Ù$95eb9f88-0403-11eb-155b-7b2d3a07cff0„´precedence_heuristic §cell_idÙ$95eb9f88-0403-11eb-155b-7b2d3a07cff0´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$955321de-0403-11eb-04ce-fb1670dfbb9e„´precedence_heuristic §cell_idÙ$955321de-0403-11eb-04ce-fb1670dfbb9e´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$ae70625a-041f-11eb-3082-0753419d6d57„´precedence_heuristic §cell_idÙ$ae70625a-041f-11eb-3082-0753419d6d57´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$843fd63c-04d0-11eb-0113-c58d346179d6„´precedence_heuristic §cell_idÙ$843fd63c-04d0-11eb-0113-c58d346179d6´downstream_cells_map�­sir_mean_plot‘Ù$7f635722-04d0-11eb-3209-4b603c9e843c²upstream_cells_map…ªNamedTuple�¦length�§missing�¥first�¦Vector�Ù$189cae1e-0424-11eb-2666-65bf297d8bdd„´precedence_heuristic §cell_idÙ$189cae1e-0424-11eb-2666-65bf297d8bdd´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7f744644-041d-11eb-08a0-3719cc0adeb7„´precedence_heuristic §cell_idÙ$7f744644-041d-11eb-08a0-3719cc0adeb7´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$488771e2-049f-11eb-3b0a-0de260457731„´precedence_heuristic §cell_idÙ$488771e2-049f-11eb-3b0a-0de260457731´downstream_cells_map€²upstream_cells_map�¯generate_agents‘Ù$7946d83a-04a0-11eb-224b-2b315e87bc84Ù$393041ec-049f-11eb-3089-2faf378445f3„´precedence_heuristic §cell_idÙ$393041ec-049f-11eb-3089-2faf378445f3´downstream_cells_map€²upstream_cells_mapÞ§@md_str�£sum�§Missing�¡!�¦Vector�¦length�§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d¢!=�¢==�¦almost‘Ù$461586dc-0414-11eb-00f3-4984b57bfac5£Set�­Base.getindex�§Nothing�ª@isdefined�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2­still_missing‘Ù$43e6e856-0414-11eb-19ca-07358aa8b667¯generate_agents‘Ù$7946d83a-04a0-11eb-224b-2b315e87bc84£isa�¤Base�£all�¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7Ù$531d13c2-0414-11eb-0acd-4905a684869d„´precedence_heuristic §cell_idÙ$531d13c2-0414-11eb-0acd-4905a684869d´downstream_cells_map€²upstream_cells_map„§@md_str�§student‘Ù$095cbf46-0403-11eb-0c37-35de9562cebc¢==�¨getindex�Ù$06f30b2a-0403-11eb-0f05-8badebe1011d„´precedence_heuristic §cell_idÙ$06f30b2a-0403-11eb-0f05-8badebe1011d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$9c39974c-04a5-11eb-184d-317eb542452c„´precedence_heuristic §cell_idÙ$9c39974c-04a5-11eb-184d-317eb542452c´downstream_cells_map€²upstream_cells_map…±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¡S‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2©interact!‘Ù$406aabea-04a5-11eb-06b8-312879457c42Ù$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1„´precedence_heuristic §cell_idÙ$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1´downstream_cells_map€²upstream_cells_map‚°large_experiment‘Ù$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8½frequencies_plot_with_maximum‘Ù$823364ce-041c-11eb-2467-7ffa4f751527Ù$06089d1e-0495-11eb-0ace-a7a7dc60e5b2„´precedence_heuristic §cell_idÙ$06089d1e-0495-11eb-0ace-a7a7dc60e5b2´downstream_cells_map€²upstream_cells_map‚°large_experiment‘Ù$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8ºfrequencies_plot_with_mean‘Ù$f1f89502-0494-11eb-2303-0b79d8bbd13fÙ$15187690-0403-11eb-2dfd-fd924faa3513„´precedence_heuristic§cell_idÙ$15187690-0403-11eb-2dfd-fd924faa3513´downstream_cells_map‚§PlutoUI�¥Plots�²upstream_cells_mapƒ§Pkg.add�£Pkg‘Ù$12cc2940-0403-11eb-19a7-bb570de58f6f¦plotly�Ù$d8abd2f6-0416-11eb-1c2a-f9157d9760a7„´precedence_heuristic §cell_idÙ$d8abd2f6-0416-11eb-1c2a-f9157d9760a7´downstream_cells_map�°small_experiment‘Ù$1ca7a8c2-041a-11eb-146a-15b8cdeaea72²upstream_cells_map�­do_experiment‘Ù$c5c7cb86-041b-11eb-3360-45463105f3c9Ù$9374e63c-0493-11eb-0952-4b97512d7cdb„´precedence_heuristic §cell_idÙ$9374e63c-0493-11eb-0952-4b97512d7cdb´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2d3bba2a-04a8-11eb-2c40-87794b6aeeac„´precedence_heuristic §cell_idÙ$2d3bba2a-04a8-11eb-2c40-87794b6aeeac´downstream_cells_map€²upstream_cells_map…§@md_str�­Base.getindex�¤Base�®Base.Docs.HTML�©@html_str�Ù$dfb99ace-04cf-11eb-0739-7d694c837d59„´precedence_heuristic §cell_idÙ$dfb99ace-04cf-11eb-0739-7d694c837d59´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$271ec5f0-041d-11eb-041b-db46ec1465e0„´precedence_heuristic §cell_idÙ$271ec5f0-041d-11eb-041b-db46ec1465e0´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7946d83a-04a0-11eb-224b-2b315e87bc84„´precedence_heuristic §cell_idÙ$7946d83a-04a0-11eb-224b-2b315e87bc84´downstream_cells_map�¯generate_agents’Ù$488771e2-049f-11eb-3b0a-0de260457731Ù$393041ec-049f-11eb-3089-2faf378445f3²upstream_cells_map‚§missing�§Integer�Ù$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9„´precedence_heuristic §cell_idÙ$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9´downstream_cells_map�©bernoulli‘Ù$b817f466-04d4-11eb-0a26-c1c667f9f7f7²upstream_cells_map‚§missing�¦Number�Ù$9635c944-0403-11eb-3982-4df509f6a556„´precedence_heuristic §cell_idÙ$9635c944-0403-11eb-3982-4df509f6a556´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$f3f81172-041c-11eb-2b9b-e99b7b9400ed„´precedence_heuristic §cell_idÙ$f3f81172-041c-11eb-2b9b-e99b7b9400ed´downstream_cells_map€²upstream_cells_map…§@md_str�­Base.getindex�¤Base�®Base.Docs.HTML�©@html_str�Ù$4ad11052-042c-11eb-3643-8b2b3e1269bc„´precedence_heuristic §cell_idÙ$4ad11052-042c-11eb-3643-8b2b3e1269bc´downstream_cells_map€²upstream_cells_map€Ù$76d117d4-0403-11eb-05d2-c5ea47d06f43„´precedence_heuristic §cell_idÙ$76d117d4-0403-11eb-05d2-c5ea47d06f43´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$095cbf46-0403-11eb-0c37-35de9562cebc„´precedence_heuristic §cell_idÙ$095cbf46-0403-11eb-0c37-35de9562cebc´downstream_cells_map�§student’Ù$03a85970-0403-11eb-334a-812b59c0905bÙ$531d13c2-0414-11eb-0acd-4905a684869d²upstream_cells_map€Ù$26e2978e-0435-11eb-0d61-25f552d2771e„´precedence_heuristic §cell_idÙ$26e2978e-0435-11eb-0d61-25f552d2771e´downstream_cells_map€²upstream_cells_map€Ù$6de37d6c-0415-11eb-1b05-85ac820016c7„´precedence_heuristic §cell_idÙ$6de37d6c-0415-11eb-1b05-85ac820016c7´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$18d308c4-0424-11eb-176d-49feec6889cf„´precedence_heuristic §cell_idÙ$18d308c4-0424-11eb-176d-49feec6889cf´downstream_cells_map�ªtest_agent�²upstream_cells_map�§missing�Ù$46133a74-04b1-11eb-0b46-0bc74e564680„´precedence_heuristic §cell_idÙ$46133a74-04b1-11eb-0b46-0bc74e564680´downstream_cells_map�¦sweep!�²upstream_cells_mapƒ±AbstractInfection‘Ù$223933a4-042c-11eb-10d3-852229f25a35¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2¦Vector�Ù$771c8f0c-0403-11eb-097e-ab24d0714ad5„´precedence_heuristic §cell_idÙ$771c8f0c-0403-11eb-097e-ab24d0714ad5´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$80c2cd88-04b1-11eb-326e-0120a39405ea„´precedence_heuristic §cell_idÙ$80c2cd88-04b1-11eb-326e-0120a39405ea´downstream_cells_map�«simulations’Ù$9cd2bb00-04b1-11eb-1d83-a703907141a7Ù$7f635722-04d0-11eb-3209-4b603c9e843c²upstream_cells_map‚²repeat_simulations‘Ù$38b1aa5a-04cf-11eb-11a2-930741fc9076±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$105d347e-041c-11eb-2fc8-1d9e5eda2be0„´precedence_heuristic §cell_idÙ$105d347e-041c-11eb-2fc8-1d9e5eda2be0´downstream_cells_map�«frequencies“Ù$1ca7a8c2-041a-11eb-146a-15b8cdeaea72Ù$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bÙ$823364ce-041c-11eb-2467-7ffa4f751527²upstream_cells_map�§missing�Ù$2c62b4ae-04b3-11eb-0080-a1035a7e31a2„´precedence_heuristic §cell_idÙ$2c62b4ae-04b3-11eb-0080-a1035a7e31a2´downstream_cells_map€²upstream_cells_map‚ªsimulation‘Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$6db6c894-0415-11eb-305a-c75b119d89e9„´precedence_heuristic §cell_idÙ$6db6c894-0415-11eb-305a-c75b119d89e9´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$77db111e-0403-11eb-2dea-4b42ceed65d6„´precedence_heuristic §cell_idÙ$77db111e-0403-11eb-2dea-4b42ceed65d6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$3d88c056-0414-11eb-0025-05d3aff1588b„´precedence_heuristic §cell_idÙ$3d88c056-0414-11eb-0025-05d3aff1588b´downstream_cells_map�§correct˜Ù$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-6f1d2c5ed272²upstream_cells_map…³Markdown.Admonition�¤yays‘Ù$3f5e0af8-0414-11eb-34a7-a71e7aaf6443«Markdown.MD�¨Markdown�¤rand�Ù$287ee7aa-0435-11eb-0ca3-951dbbe69404„´precedence_heuristic §cell_idÙ$287ee7aa-0435-11eb-0ca3-951dbbe69404´downstream_cells_map�³sir_mean_error_plot�²upstream_cells_map…ªNamedTuple�¦length�§missing�¥first�¦Vector�Ù$03a85970-0403-11eb-334a-812b59c0905b„´precedence_heuristic §cell_idÙ$03a85970-0403-11eb-334a-812b59c0905b´downstream_cells_map€²upstream_cells_mapƒ§@md_str�§student‘Ù$095cbf46-0403-11eb-0c37-35de9562cebc¨getindex�Ù$6d906d0c-0415-11eb-0c1c-b5c0aca841db„´precedence_heuristic §cell_idÙ$6d906d0c-0415-11eb-0c1c-b5c0aca841db´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¤hint‘Ù$48a16c42-0414-11eb-0e0c-bf52bbb0f618¨getindex�Ù$866299e8-0403-11eb-085d-2b93459cc141„´precedence_heuristic §cell_idÙ$866299e8-0403-11eb-085d-2b93459cc141´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$461586dc-0414-11eb-00f3-4984b57bfac5„´precedence_heuristic §cell_idÙ$461586dc-0414-11eb-00f3-4984b57bfac5´downstream_cells_map�¦almost’Ù$393041ec-049f-11eb-3089-2faf378445f3Ù$759bc42e-04ab-11eb-0ab1-b12e008c02a9²upstream_cells_mapƒ³Markdown.Admonition�«Markdown.MD�¨Markdown�Ù$c5156c72-04af-11eb-1106-b13969b036ca„´precedence_heuristic §cell_idÙ$c5156c72-04af-11eb-1106-b13969b036ca´downstream_cells_map€²upstream_cells_map†¡:�¤plot�­run_basic_sir‘Ù$28db9d98-04ca-11eb-3606-9fb89fa62f36ªsimulation‘Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8¥plot!�±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21f„´precedence_heuristic §cell_idÙ$c4a8694a-04d4-11eb-1eef-c9e037e6b21f´downstream_cells_map€²upstream_cells_mapÞ§@md_str�­Base.getindex�§Missing�¡!�®is_susceptible‘Ù$9a837b52-0425-11eb-231f-a74405ff6e23ª@isdefined�¤Bool�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2­still_missing‘Ù$43e6e856-0414-11eb-19ca-07358aa8b667«is_infected‘Ù$a8dd5cae-0425-11eb-119c-bfcbf832d695£isa�¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¡S‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7£===�¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68¤Base�«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¡R‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7Ù$1491a078-04aa-11eb-0106-19a3cf1e94b0„´precedence_heuristic §cell_idÙ$1491a078-04aa-11eb-0106-19a3cf1e94b0´downstream_cells_map€²upstream_cells_mapÞ§@md_str�­Base.getindex�¡!�ª@isdefined�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2©interact!‘Ù$406aabea-04a5-11eb-06b8-312879457c42¤Base�¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¡S‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d¢!=�¡R‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¢==�±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$c5c7cb86-041b-11eb-3360-45463105f3c9„´precedence_heuristic §cell_idÙ$c5c7cb86-041b-11eb-3360-45463105f3c9´downstream_cells_map�­do_experiment’Ù$d8abd2f6-0416-11eb-1c2a-f9157d9760a7Ù$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8²upstream_cells_map�§missing�Ù$01341648-0403-11eb-2212-db450c299f35„´precedence_heuristic §cell_idÙ$01341648-0403-11eb-2212-db450c299f35´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$48a16c42-0414-11eb-0e0c-bf52bbb0f618„´precedence_heuristic §cell_idÙ$48a16c42-0414-11eb-0e0c-bf52bbb0f618´downstream_cells_map�¤hint“Ù$6d906d0c-0415-11eb-0c1c-b5c0aca841dbÙ$08e2bc64-0417-11eb-1457-21c0d18e8c51Ù$9cf9080a-04b1-11eb-12a0-17013f2d37f5²upstream_cells_mapƒ³Markdown.Admonition�«Markdown.MD�¨Markdown�Ù$98beb336-0425-11eb-3886-4f8cfd210288„´precedence_heuristic §cell_idÙ$98beb336-0425-11eb-3886-4f8cfd210288´downstream_cells_map�«set_status!‘Ù$7c515a7a-04d5-11eb-0f36-4fcebff709d5²upstream_cells_map‚¯InfectionStatus‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Ù$bb63f3cc-042f-11eb-04ff-a128aec3c378„´precedence_heuristic §cell_idÙ$bb63f3cc-042f-11eb-04ff-a128aec3c378´downstream_cells_map€²upstream_cells_map€Ù$61c00724-0403-11eb-228d-17c11670e5d1„´precedence_heuristic §cell_idÙ$61c00724-0403-11eb-228d-17c11670e5d1´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$9cf9080a-04b1-11eb-12a0-17013f2d37f5„´precedence_heuristic §cell_idÙ$9cf9080a-04b1-11eb-12a0-17013f2d37f5´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¤hint‘Ù$48a16c42-0414-11eb-0e0c-bf52bbb0f618¨getindex�Ù$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8„´precedence_heuristic §cell_idÙ$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8´downstream_cells_map�°large_experiment“Ù$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bÙ$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1Ù$06089d1e-0495-11eb-0ace-a7a7dc60e5b2²upstream_cells_map�­do_experiment‘Ù$c5c7cb86-041b-11eb-3360-45463105f3c9Ù$61789646-0403-11eb-0042-f3b8308f11ba„´precedence_heuristic §cell_idÙ$61789646-0403-11eb-0042-f3b8308f11ba´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$39dffa3c-0414-11eb-0197-e72b299e9c63„´precedence_heuristic §cell_idÙ$39dffa3c-0414-11eb-0197-e72b299e9c63´downstream_cells_map�¨bigbreak’Ù$2b26dc42-0403-11eb-205f-cd2c23d8cb03Ù$5689841e-0414-11eb-0492-63c77ddbd136²upstream_cells_mapƒ¤Base�®Base.Docs.HTML�©@html_str�Ù$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272„´precedence_heuristic §cell_idÙ$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272´downstream_cells_map€²upstream_cells_map�§@md_str�­Base.getindex�¡!�ª@isdefined�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2©interact!‘Ù$406aabea-04a5-11eb-06b8-312879457c42¤Base�¡I‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d¢!=�¡R‘Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7¢==�±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$88c53208-041d-11eb-3b1e-31b57ba99f05„´precedence_heuristic §cell_idÙ$88c53208-041d-11eb-3b1e-31b57ba99f05´downstream_cells_map€²upstream_cells_map€Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8„´precedence_heuristic §cell_idÙ$887d27fc-04bc-11eb-0ab9-eb95ef9607f8´downstream_cells_map�ªsimulation”Ù$b92f1cec-04ae-11eb-0072-3535d1118494Ù$2c62b4ae-04b3-11eb-0080-a1035a7e31a2Ù$c5156c72-04af-11eb-1106-b13969b036caÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076²upstream_cells_mapƒ§missing�±AbstractInfection‘Ù$223933a4-042c-11eb-10d3-852229f25a35§Integer�Ù$d57c6a5a-041b-11eb-3ab4-774a2d45a891„´precedence_heuristic §cell_idÙ$d57c6a5a-041b-11eb-3ab4-774a2d45a891´downstream_cells_map�­recovery_time‘Ù$c61f35ea-04d6-11eb-2503-17a79f8d0298²upstream_cells_map…¢<=�§missing�¥throw�£â‰¤�­ArgumentError�Ù$12cc2940-0403-11eb-19a7-bb570de58f6f„´precedence_heuristic§cell_idÙ$12cc2940-0403-11eb-19a7-bb570de58f6f´downstream_cells_map�£Pkg’Ù$12cc2940-0403-11eb-19a7-bb570de58f6fÙ$15187690-0403-11eb-2dfd-fd924faa3513²upstream_cells_mapƒ£Pkg‘Ù$12cc2940-0403-11eb-19a7-bb570de58f6f¬Pkg.activate�©mktempdir�Ù$76f62d64-0403-11eb-27e2-3de58366b619„´precedence_heuristic §cell_idÙ$76f62d64-0403-11eb-27e2-3de58366b619´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$860790fc-0403-11eb-2f2e-355f77dcc7af„´precedence_heuristic §cell_idÙ$860790fc-0403-11eb-2f2e-355f77dcc7af´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$b21475c6-04ac-11eb-1366-f3b5e967402d„´precedence_heuristic §cell_idÙ$b21475c6-04ac-11eb-1366-f3b5e967402d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$823364ce-041c-11eb-2467-7ffa4f751527„´precedence_heuristic §cell_idÙ$823364ce-041c-11eb-2467-7ffa4f751527´downstream_cells_map�½frequencies_plot_with_maximum‘Ù$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1²upstream_cells_map…£bar�¦vline!�«frequencies‘Ù$105d347e-041c-11eb-2fc8-1d9e5eda2be0§maximum�¦Vector�Ù$619c8a10-0403-11eb-2e89-8b0974fb01d0„´precedence_heuristic §cell_idÙ$619c8a10-0403-11eb-2e89-8b0974fb01d0´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$38b1aa5a-04cf-11eb-11a2-930741fc9076„´precedence_heuristic §cell_idÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076´downstream_cells_map�²repeat_simulations‘Ù$80c2cd88-04b1-11eb-326e-0120a39405ea²upstream_cells_mapƒ¡:�£map�ªsimulation‘Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8Ù$8dd97820-04a5-11eb-36c0-8f92d4b859a8„´precedence_heuristic §cell_idÙ$8dd97820-04a5-11eb-36c0-8f92d4b859a8´downstream_cells_map€²upstream_cells_map€Ù$df8547b4-0400-11eb-07c6-fb370b61c2b6„´precedence_heuristic §cell_idÙ$df8547b4-0400-11eb-07c6-fb370b61c2b6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$1d3356c4-0403-11eb-0f48-01b5eb14a585„´precedence_heuristic §cell_idÙ$1d3356c4-0403-11eb-0f48-01b5eb14a585´downstream_cells_map€²upstream_cells_mapƒ¤Base�®Base.Docs.HTML�©@html_str�Ù$82f2580a-04c8-11eb-1eea-bdb4e50eee3b„´precedence_heuristic §cell_idÙ$82f2580a-04c8-11eb-1eea-bdb4e50eee3b´downstream_cells_map€²upstream_cells_map�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Ù$86d98d0a-0403-11eb-215b-c58ad721a90b„´precedence_heuristic §cell_idÙ$86d98d0a-0403-11eb-215b-c58ad721a90b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$dc784864-0430-11eb-1478-d1153e017310„´precedence_heuristic §cell_idÙ$dc784864-0430-11eb-1478-d1153e017310´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$3f5e0af8-0414-11eb-34a7-a71e7aaf6443„´precedence_heuristic §cell_idÙ$3f5e0af8-0414-11eb-34a7-a71e7aaf6443´downstream_cells_map�¤yays‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b²upstream_cells_map‚§@md_str�¨getindex�Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d„´precedence_heuristic §cell_idÙ$3c0528a0-0414-11eb-2f68-a5657ab9e73d´downstream_cells_map�«not_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-6f1d2c5ed272²upstream_cells_map‡§@md_str�¦string�³Markdown.Admonition�«Markdown.MD�­Markdown.Code�¨Markdown�¨getindex�Ù$7335de44-042f-11eb-2873-8bceef722432„´precedence_heuristic §cell_idÙ$7335de44-042f-11eb-2873-8bceef722432´downstream_cells_map€²upstream_cells_map€Ù$406aabea-04a5-11eb-06b8-312879457c42„´precedence_heuristic §cell_idÙ$406aabea-04a5-11eb-06b8-312879457c42´downstream_cells_map�©interact!”Ù$9c39974c-04a5-11eb-184d-317eb542452cÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9Ù$1491a078-04aa-11eb-0106-19a3cf1e94b0Ù$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272²upstream_cells_map‚¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$c61f35ea-04d6-11eb-2503-17a79f8d0298„´precedence_heuristic §cell_idÙ$c61f35ea-04d6-11eb-2503-17a79f8d0298´downstream_cells_map€²upstream_cells_mapÞ§@md_str�­Base.getindex�§extrema�§Missing�­recovery_time‘Ù$d57c6a5a-041b-11eb-3ab4-774a2d45a891¡:�¡>�¡!�¦isless�ª@isdefined�§Integer�­still_missing‘Ù$43e6e856-0414-11eb-19ca-07358aa8b667£isa�¡<�¤Base�§correct‘Ù$3d88c056-0414-11eb-0025-05d3aff1588b¬keep_working‘Ù$41cefa68-0414-11eb-3bad-6530360d6f68«not_defined‘Ù$3c0528a0-0414-11eb-2f68-a5657ab9e73d¢==�Ù$9cd2bb00-04b1-11eb-1d83-a703907141a7„´precedence_heuristic §cell_idÙ$9cd2bb00-04b1-11eb-1d83-a703907141a7´downstream_cells_map€²upstream_cells_map…«simulations‘Ù$80c2cd88-04b1-11eb-326e-0120a39405ea¡:�¤plot�¥plot!�§nothing�Ù$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b„´precedence_heuristic §cell_idÙ$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b´downstream_cells_map€²upstream_cells_mapƒ£bar�°large_experiment‘Ù$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8«frequencies‘Ù$105d347e-041c-11eb-2fc8-1d9e5eda2be0Ù$8631a536-0403-11eb-0379-bb2e56927727„´precedence_heuristic §cell_idÙ$8631a536-0403-11eb-0379-bb2e56927727´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$9a13b17c-0403-11eb-024f-9b37e95e211b„´precedence_heuristic §cell_idÙ$9a13b17c-0403-11eb-024f-9b37e95e211b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$b92f1cec-04ae-11eb-0072-3535d1118494„´precedence_heuristic §cell_idÙ$b92f1cec-04ae-11eb-0072-3535d1118494´downstream_cells_map€²upstream_cells_map‚ªsimulation‘Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8±InfectionRecovery‘Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$9a377b32-0403-11eb-2799-e7e59caa6a45„´precedence_heuristic §cell_idÙ$9a377b32-0403-11eb-2799-e7e59caa6a45´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$778ec25c-0403-11eb-3146-1d11c294bb1f„´precedence_heuristic §cell_idÙ$778ec25c-0403-11eb-3146-1d11c294bb1f´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$9611ca24-0403-11eb-3582-b7e3bb243e62„´precedence_heuristic §cell_idÙ$9611ca24-0403-11eb-3582-b7e3bb243e62´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$26f84600-041d-11eb-1856-b12a3e5c1dc7„´precedence_heuristic §cell_idÙ$26f84600-041d-11eb-1856-b12a3e5c1dc7´downstream_cells_map‡·Base.Enums.Base.typemin�·Base.Enums.Base.typemax�¡I—Ù$7c515a7a-04d5-11eb-0f36-4fcebff709d5Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21fÙ$393041ec-049f-11eb-3089-2faf378445f3Ù$9c39974c-04a5-11eb-184d-317eb542452cÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9Ù$1491a078-04aa-11eb-0106-19a3cf1e94b0Ù$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272¡S”Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21fÙ$9c39974c-04a5-11eb-184d-317eb542452cÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9Ù$1491a078-04aa-11eb-0106-19a3cf1e94b0¯InfectionStatus’Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Ù$98beb336-0425-11eb-3886-4f8cfd210288¡R•Ù$7c515a7a-04d5-11eb-0f36-4fcebff709d5Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21fÙ$759bc42e-04ab-11eb-0ab1-b12e008c02a9Ù$1491a078-04aa-11eb-0106-19a3cf1e94b0Ù$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272¸Base.Enums.Enums.namemap�²upstream_cells_map‡¤Base�­Base.@__doc__�¥@enum�¾Base.Enums.enum_argument_error�¥Enums�²Base.Enums.convert�²Base.Enums.bitcast�Ù$1ca7a8c2-041a-11eb-146a-15b8cdeaea72„´precedence_heuristic §cell_idÙ$1ca7a8c2-041a-11eb-146a-15b8cdeaea72´downstream_cells_map€²upstream_cells_map‚°small_experiment‘Ù$d8abd2f6-0416-11eb-1c2a-f9157d9760a7«frequencies‘Ù$105d347e-041c-11eb-2fc8-1d9e5eda2be0Ù$190deebc-0424-11eb-19fe-615997093e14„´precedence_heuristic §cell_idÙ$190deebc-0424-11eb-19fe-615997093e14´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$1a654bdc-0421-11eb-2c38-7d35060e2565„´precedence_heuristic §cell_idÙ$1a654bdc-0421-11eb-2c38-7d35060e2565´downstream_cells_map�±InfectionRecovery™Ù$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Ù$b92f1cec-04ae-11eb-0072-3535d1118494Ù$2c62b4ae-04b3-11eb-0080-a1035a7e31a2Ù$c5156c72-04af-11eb-1106-b13969b036caÙ$80c2cd88-04b1-11eb-326e-0120a39405ea²upstream_cells_map�±AbstractInfection‘Ù$223933a4-042c-11eb-10d3-852229f25a35Ù$41cefa68-0414-11eb-3bad-6530360d6f68„´precedence_heuristic §cell_idÙ$41cefa68-0414-11eb-3bad-6530360d6f68´downstream_cells_map�¬keep_working˜Ù$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-6f1d2c5ed272²upstream_cells_map…§@md_str�³Markdown.Admonition�«Markdown.MD�¨Markdown�¨getindex�Ù$847d0fc2-041d-11eb-2864-79066e223b45„´precedence_heuristic §cell_idÙ$847d0fc2-041d-11eb-2864-79066e223b45´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$77428072-0403-11eb-0068-81e3728f2ebe„´precedence_heuristic §cell_idÙ$77428072-0403-11eb-0068-81e3728f2ebe´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$9a837b52-0425-11eb-231f-a74405ff6e23„´precedence_heuristic §cell_idÙ$9a837b52-0425-11eb-231f-a74405ff6e23´downstream_cells_map�®is_susceptible‘Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21f²upstream_cells_map‚§missing�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Ù$0a967f38-0493-11eb-0624-77e40b24d757„´precedence_heuristic §cell_idÙ$0a967f38-0493-11eb-0624-77e40b24d757´downstream_cells_map€²upstream_cells_map…§@md_str�­Base.getindex�¤Base�®Base.Docs.HTML�©@html_str�Ù$28db9d98-04ca-11eb-3606-9fb89fa62f36„´precedence_heuristic §cell_idÙ$28db9d98-04ca-11eb-3606-9fb89fa62f36´downstream_cells_map�­run_basic_sir‘Ù$c5156c72-04af-11eb-1106-b13969b036ca²upstream_cells_mapˆ¤Core�¤Base�·PlutoRunner.create_bond�«PlutoRunner�¯Core.applicable�¥@bind�¦Button�¨Base.get�Ù$8692bf42-0403-11eb-191f-b7d08895274f„´precedence_heuristic §cell_idÙ$8692bf42-0403-11eb-191f-b7d08895274f´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$da49710e-0420-11eb-092e-4f1173868738„´precedence_heuristic §cell_idÙ$da49710e-0420-11eb-092e-4f1173868738´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7bb8e426-0495-11eb-3a8b-cbbab61a1631„´precedence_heuristic §cell_idÙ$7bb8e426-0495-11eb-3a8b-cbbab61a1631´downstream_cells_map€²upstream_cells_map€Ù$21c50840-0435-11eb-1307-7138ecde0691„´precedence_heuristic §cell_idÙ$21c50840-0435-11eb-1307-7138ecde0691´downstream_cells_map€²upstream_cells_map€Ù$2ade2694-0425-11eb-2fb2-390da43d9695„´precedence_heuristic §cell_idÙ$2ade2694-0425-11eb-2fb2-390da43d9695´downstream_cells_map�¥step!�²upstream_cells_mapƒ±AbstractInfection‘Ù$223933a4-042c-11eb-10d3-852229f25a35¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2¦Vector�Ù$bf6fd176-04cc-11eb-008a-2fb6ff70a9cb„´precedence_heuristic §cell_idÙ$bf6fd176-04cc-11eb-008a-2fb6ff70a9cb´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$73047bba-0416-11eb-1047-23e9c3dbde05„´precedence_heuristic §cell_idÙ$73047bba-0416-11eb-1047-23e9c3dbde05´downstream_cells_map�¾interpretation_of_p_equals_one�²upstream_cells_map‚§@md_str�¨getindex�Ù$43e6e856-0414-11eb-19ca-07358aa8b667„´precedence_heuristic §cell_idÙ$43e6e856-0414-11eb-19ca-07358aa8b667´downstream_cells_map�­still_missing”Ù$b817f466-04d4-11eb-0a26-c1c667f9f7f7Ù$c61f35ea-04d6-11eb-2503-17a79f8d0298Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21fÙ$393041ec-049f-11eb-3089-2faf378445f3²upstream_cells_map…§@md_str�³Markdown.Admonition�«Markdown.MD�¨Markdown�¨getindex�Ù$2b26dc42-0403-11eb-205f-cd2c23d8cb03„´precedence_heuristic §cell_idÙ$2b26dc42-0403-11eb-205f-cd2c23d8cb03´downstream_cells_map€²upstream_cells_map�¨bigbreak‘Ù$39dffa3c-0414-11eb-0197-e72b299e9c63Ù$95c598d4-0403-11eb-2328-0175ed564915„´precedence_heuristic §cell_idÙ$95c598d4-0403-11eb-2328-0175ed564915´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$1ac4b33a-0435-11eb-36f8-8f3f81ae7844„´precedence_heuristic §cell_idÙ$1ac4b33a-0435-11eb-36f8-8f3f81ae7844´downstream_cells_map€²upstream_cells_map€Ù$a8dd5cae-0425-11eb-119c-bfcbf832d695„´precedence_heuristic §cell_idÙ$a8dd5cae-0425-11eb-119c-bfcbf832d695´downstream_cells_map�«is_infected‘Ù$c4a8694a-04d4-11eb-1eef-c9e037e6b21f²upstream_cells_map‚§missing�¥Agent‘Ù$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2´cell_execution_orderÜ€Ù$12cc2940-0403-11eb-19a7-bb570de58f6fÙ$15187690-0403-11eb-2dfd-fd924faa3513Ù$01341648-0403-11eb-2212-db450c299f35Ù$06f30b2a-0403-11eb-0f05-8badebe1011dÙ$095cbf46-0403-11eb-0c37-35de9562cebcÙ$03a85970-0403-11eb-334a-812b59c0905bÙ$107e65a4-0403-11eb-0c14-37d8d828b469Ù$1d3356c4-0403-11eb-0f48-01b5eb14a585Ù$df8547b4-0400-11eb-07c6-fb370b61c2b6Ù$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9Ù$76d117d4-0403-11eb-05d2-c5ea47d06f43Ù$d57c6a5a-041b-11eb-3ab4-774a2d45a891Ù$6db6c894-0415-11eb-305a-c75b119d89e9Ù$6de37d6c-0415-11eb-1b05-85ac820016c7Ù$73047bba-0416-11eb-1047-23e9c3dbde05Ù$76f62d64-0403-11eb-27e2-3de58366b619Ù$c5c7cb86-041b-11eb-3360-45463105f3c9Ù$d8abd2f6-0416-11eb-1c2a-f9157d9760a7Ù$771c8f0c-0403-11eb-097e-ab24d0714ad5Ù$105d347e-041c-11eb-2fc8-1d9e5eda2be0Ù$1ca7a8c2-041a-11eb-146a-15b8cdeaea72Ù$77428072-0403-11eb-0068-81e3728f2ebeÙ$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8Ù$dc784864-0430-11eb-1478-d1153e017310Ù$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9bÙ$9374e63c-0493-11eb-0952-4b97512d7cdbÙ$823364ce-041c-11eb-2467-7ffa4f751527Ù$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1Ù$f3f81172-041c-11eb-2b9b-e99b7b9400edÙ$7768a2dc-0403-11eb-39b7-fd660dc952feÙ$f1f89502-0494-11eb-2303-0b79d8bbd13fÙ$06089d1e-0495-11eb-0ace-a7a7dc60e5b2Ù$77b54c10-0403-11eb-16ad-65374d29a817Ù$bb63f3cc-042f-11eb-04ff-a128aec3c378Ù$bb8aeb58-042f-11eb-18b8-f995631df619Ù$778ec25c-0403-11eb-3146-1d11c294bb1fÙ$7bb8e426-0495-11eb-3a8b-cbbab61a1631Ù$77db111e-0403-11eb-2dea-4b42ceed65d6Ù$7335de44-042f-11eb-2873-8bceef722432Ù$61789646-0403-11eb-0042-f3b8308f11baÙ$26f84600-041d-11eb-1856-b12a3e5c1dc7Ù$271ec5f0-041d-11eb-041b-db46ec1465e0Ù$7f4e121c-041d-11eb-0dff-cd0cbfdfd606Ù$7f744644-041d-11eb-08a0-3719cc0adeb7Ù$88c53208-041d-11eb-3b1e-31b57ba99f05Ù$847d0fc2-041d-11eb-2864-79066e223b45Ù$860790fc-0403-11eb-2f2e-355f77dcc7afÙ$ae4ac4b4-041f-11eb-14f5-1bcde35d18f2Ù$ae70625a-041f-11eb-3082-0753419d6d57Ù$60a8b708-04c8-11eb-37b1-3daec644ac90Ù$189cae1e-0424-11eb-2666-65bf297d8bddÙ$18d308c4-0424-11eb-176d-49feec6889cfÙ$190deebc-0424-11eb-19fe-615997093e14Ù$82f2580a-04c8-11eb-1eea-bdb4e50eee3bÙ$8631a536-0403-11eb-0379-bb2e56927727Ù$98beb336-0425-11eb-3886-4f8cfd210288Ù$866299e8-0403-11eb-085d-2b93459cc141Ù$9a837b52-0425-11eb-231f-a74405ff6e23Ù$a8dd5cae-0425-11eb-119c-bfcbf832d695Ù$8692bf42-0403-11eb-191f-b7d08895274fÙ$7946d83a-04a0-11eb-224b-2b315e87bc84Ù$488771e2-049f-11eb-3b0a-0de260457731Ù$86d98d0a-0403-11eb-215b-c58ad721a90bÙ$223933a4-042c-11eb-10d3-852229f25a35Ù$1a654bdc-0421-11eb-2c38-7d35060e2565Ù$2d3bba2a-04a8-11eb-2c40-87794b6aeeacÙ$406aabea-04a5-11eb-06b8-312879457c42Ù$b21475c6-04ac-11eb-1366-f3b5e967402dÙ$9c39974c-04a5-11eb-184d-317eb542452cÙ$619c8a10-0403-11eb-2e89-8b0974fb01d0Ù$2ade2694-0425-11eb-2fb2-390da43d9695Ù$955321de-0403-11eb-04ce-fb1670dfbb9eÙ$46133a74-04b1-11eb-0b46-0bc74e564680Ù$95771ce2-0403-11eb-3056-f1dc3a8b7ec3Ù$887d27fc-04bc-11eb-0ab9-eb95ef9607f8Ù$b92f1cec-04ae-11eb-0072-3535d1118494Ù$2c62b4ae-04b3-11eb-0080-a1035a7e31a2Ù$28db9d98-04ca-11eb-3606-9fb89fa62f36Ù$c5156c72-04af-11eb-1106-b13969b036caÙ$0a967f38-0493-11eb-0624-77e40b24d757Ù$bf6fd176-04cc-11eb-008a-2fb6ff70a9cbÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076Ù$80c2cd88-04b1-11eb-326e-0120a39405eaÙ$80e6f1e0-04b1-11eb-0d4e-475f1d80c2bbÙ$9cd2bb00-04b1-11eb-1d83-a703907141a7Ù$95c598d4-0403-11eb-2328-0175ed564915Ù$843fd63c-04d0-11eb-0113-c58d346179d6Ù$7f635722-04d0-11eb-3209-4b603c9e843cÙ$dfb99ace-04cf-11eb-0739-7d694c837d59Ù$1c6aa208-04d1-11eb-0b87-cf429e6ff6d0Ù$95eb9f88-0403-11eb-155b-7b2d3a07cff0Ù$287ee7aa-0435-11eb-0ca3-951dbbe69404Ù$9611ca24-0403-11eb-3582-b7e3bb243e62Ù$26e2978e-0435-11eb-0d61-25f552d2771eÙ$9635c944-0403-11eb-3982-4df509f6a556Ù$4ad11052-042c-11eb-3643-8b2b3e1269bcÙ$61c00724-0403-11eb-228d-17c11670e5d1Ù$8dd97820-04a5-11eb-36c0-8f92d4b859a8Ù$99ef7b2a-0403-11eb-08ef-e1023cd151aeÙ$9a13b17c-0403-11eb-024f-9b37e95e211bÙ$1ac4b33a-0435-11eb-36f8-8f3f81ae7844Ù$9a377b32-0403-11eb-2799-e7e59caa6a45Ù$21c50840-0435-11eb-1307-7138ecde0691Ù$da49710e-0420-11eb-092e-4f1173868738Ù$e6219c7c-0420-11eb-3faa-13126f7c8007Ù$531d13c2-0414-11eb-0acd-4905a684869dÙ$4f19e872-0414-11eb-0dfd-e53d2aecc4dcÙ$48a16c42-0414-11eb-0e0c-bf52bbb0f618Ù$6d906d0c-0415-11eb-0c1c-b5c0aca841dbÙ$08e2bc64-0417-11eb-1457-21c0d18e8c51Ù$9cf9080a-04b1-11eb-12a0-17013f2d37f5Ù$461586dc-0414-11eb-00f3-4984b57bfac5Ù$43e6e856-0414-11eb-19ca-07358aa8b667Ù$41cefa68-0414-11eb-3bad-6530360d6f68Ù$3f5e0af8-0414-11eb-34a7-a71e7aaf6443Ù$3d88c056-0414-11eb-0025-05d3aff1588bÙ$3c0528a0-0414-11eb-2f68-a5657ab9e73dÙ$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-6f1d2c5ed272Ù$39dffa3c-0414-11eb-0197-e72b299e9c63Ù$2b26dc42-0403-11eb-205f-cd2c23d8cb03Ù$5689841e-0414-11eb-0492-63c77ddbd136´last_hot_reload_timeË©shortpath¦hw4.jl®process_status¥ready¤pathÙ 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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$531d13c2-0414-11eb-0acd-4905a684869d„§cell_idÙ$531d13c2-0414-11eb-0acd-4905a684869d¤codeÙ¦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. """ end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$06f30b2a-0403-11eb-0f05-8badebe1011d„§cell_idÙ$06f30b2a-0403-11eb-0f05-8badebe1011d¤codeÚmd""" # **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! """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9c39974c-04a5-11eb-184d-317eb542452c„§cell_idÙ$9c39974c-04a5-11eb-184d-317eb542452c¤codeÙ¢let agent = Agent(S, 0) source = Agent(I, 0) infection = InfectionRecovery(0.9, 0.5) interact!(agent, source, infection) (agent=agent, source=source) end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1„§cell_idÙ$1ddbaa18-0494-11eb-1fc8-250ab6ae89f1¤codeÙ/frequencies_plot_with_maximum(large_experiment)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$06089d1e-0495-11eb-0ace-a7a7dc60e5b2„§cell_idÙ$06089d1e-0495-11eb-0ace-a7a7dc60e5b2¤codeÙ,frequencies_plot_with_mean(large_experiment)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$15187690-0403-11eb-2dfd-fd924faa3513„§cell_idÙ$15187690-0403-11eb-2dfd-fd924faa3513¤codeÙPbegin Pkg.add(["Plots", "PlutoUI",]) using Plots plotly() using PlutoUI end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$d8abd2f6-0416-11eb-1c2a-f9157d9760a7„§cell_idÙ$d8abd2f6-0416-11eb-1c2a-f9157d9760a7¤codeÙ)small_experiment = do_experiment(0.5, 20)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$9374e63c-0493-11eb-0952-4b97512d7cdb„§cell_idÙ$9374e63c-0493-11eb-0952-4b97512d7cdb¤codeÚ*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). """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2d3bba2a-04a8-11eb-2c40-87794b6aeeac„§cell_idÙ$2d3bba2a-04a8-11eb-2c40-87794b6aeeac¤codeÚˆmd""" #### 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"") """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$dfb99ace-04cf-11eb-0739-7d694c837d59„§cell_idÙ$dfb99ace-04cf-11eb-0739-7d694c837d59¤codeÙ£md""" 👉 Allow $p_\text{infection}$ and $p_\text{recovery}$ to be changed interactively and find parameter values for which you observe an epidemic outbreak. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$271ec5f0-041d-11eb-041b-db46ec1465e0„§cell_idÙ$271ec5f0-041d-11eb-041b-db46ec1465e0¤codeÙämd""" 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`. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$7946d83a-04a0-11eb-224b-2b315e87bc84„§cell_idÙ$7946d83a-04a0-11eb-224b-2b315e87bc84¤codeÙ:function generate_agents(N::Integer) return missing end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9„§cell_idÙ$02b0c2fc-0415-11eb-2b40-7bca8ea4eef9¤codeÙ3function bernoulli(p::Number) return missing end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$9635c944-0403-11eb-3982-4df509f6a556„§cell_idÙ$9635c944-0403-11eb-3982-4df509f6a556¤codeÙàmd""" #### 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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$f3f81172-041c-11eb-2b9b-e99b7b9400ed„§cell_idÙ$f3f81172-041c-11eb-2b9b-e99b7b9400ed¤codeÚ+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)! """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4ad11052-042c-11eb-3643-8b2b3e1269bc„§cell_idÙ$4ad11052-042c-11eb-3643-8b2b3e1269bc¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$76d117d4-0403-11eb-05d2-c5ea47d06f43„§cell_idÙ$76d117d4-0403-11eb-05d2-c5ea47d06f43¤codeÙjmd""" 👉 Write a function `recovery_time(p)` that returns the time taken until the person recovers. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$095cbf46-0403-11eb-0c37-35de9562cebc„§cell_idÙ$095cbf46-0403-11eb-0c37-35de9562cebc¤codeÚ# 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 up¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$26e2978e-0435-11eb-0d61-25f552d2771e„§cell_idÙ$26e2978e-0435-11eb-0d61-25f552d2771e¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$6de37d6c-0415-11eb-1b05-85ac820016c7„§cell_idÙ$6de37d6c-0415-11eb-1b05-85ac820016c7¤codeÙ'md""" 👉 What happens for $p=1$? """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$18d308c4-0424-11eb-176d-49feec6889cf„§cell_idÙ$18d308c4-0424-11eb-176d-49feec6889cf¤code´test_agent = missing¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$46133a74-04b1-11eb-0b46-0bc74e564680„§cell_idÙ$46133a74-04b1-11eb-0b46-0bc74e564680¤codeÙZfunction sweep!(agents::Vector{Agent}, infection::AbstractInfection) # your code here end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$771c8f0c-0403-11eb-097e-ab24d0714ad5„§cell_idÙ$771c8f0c-0403-11eb-097e-ab24d0714ad5¤codeÚ7md""" #### 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$. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$80c2cd88-04b1-11eb-326e-0120a39405ea„§cell_idÙ$80c2cd88-04b1-11eb-326e-0120a39405ea¤codeÙOsimulations = repeat_simulations(100, 1000, InfectionRecovery(0.02, 0.002), 20)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$105d347e-041c-11eb-2fc8-1d9e5eda2be0„§cell_idÙ$105d347e-041c-11eb-2fc8-1d9e5eda2be0¤codeÙ2function frequencies(values) return missing end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$2c62b4ae-04b3-11eb-0080-a1035a7e31a2„§cell_idÙ$2c62b4ae-04b3-11eb-0080-a1035a7e31a2¤codeÙ4simulation(100, 1000, InfectionRecovery(0.005, 0.2))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$6db6c894-0415-11eb-305a-c75b119d89e9„§cell_idÙ$6db6c894-0415-11eb-305a-c75b119d89e9¤codeÚDmd""" 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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$77db111e-0403-11eb-2dea-4b42ceed65d6„§cell_idÙ$77db111e-0403-11eb-2dea-4b42ceed65d6¤codeÙ¾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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3d88c056-0414-11eb-0025-05d3aff1588b„§cell_idÙ$3d88c056-0414-11eb-0025-05d3aff1588b¤codeÙYcorrect(text=rand(yays)) = Markdown.MD(Markdown.Admonition("correct", "Got it!", [text]))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$287ee7aa-0435-11eb-0ca3-951dbbe69404„§cell_idÙ$287ee7aa-0435-11eb-0ca3-951dbbe69404¤codeÙ¸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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$03a85970-0403-11eb-334a-812b59c0905b„§cell_idÙ$03a85970-0403-11eb-334a-812b59c0905b¤codeÙPmd""" Submission by: **_$(student.name)_** ($(student.kerberos_id)@mit.edu) """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$6d906d0c-0415-11eb-0c1c-b5c0aca841db„§cell_idÙ$6d906d0c-0415-11eb-0c1c-b5c0aca841db¤codeÙ{hint(md"Remember to always re-use work you have done previously: in this case you should re-use the function `bernoulli`.")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$866299e8-0403-11eb-085d-2b93459cc141„§cell_idÙ$866299e8-0403-11eb-085d-2b93459cc141¤codeÙ‰md""" 👉 We will also need functions `is_susceptible` and `is_infected` that check if a given agent is in those respective states. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$461586dc-0414-11eb-00f3-4984b57bfac5„§cell_idÙ$461586dc-0414-11eb-00f3-4984b57bfac5¤codeÙSalmost(text) = Markdown.MD(Markdown.Admonition("warning", "Almost there!", [text]))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$c5156c72-04af-11eb-1106-b13969b036ca„§cell_idÙ$c5156c72-04af-11eb-1106-b13969b036ca¤codeÚlet 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") end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$c4a8694a-04d4-11eb-1eef-c9e037e6b21f„§cell_idÙ$c4a8694a-04d4-11eb-1eef-c9e037e6b21f¤codeÚif !@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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$1491a078-04aa-11eb-0106-19a3cf1e94b0„§cell_idÙ$1491a078-04aa-11eb-0106-19a3cf1e94b0¤codeÚžif !@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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$c5c7cb86-041b-11eb-3360-45463105f3c9„§cell_idÙ$c5c7cb86-041b-11eb-3360-45463105f3c9¤codeÙ2function do_experiment(p, N) return missing end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$01341648-0403-11eb-2212-db450c299f35„§cell_idÙ$01341648-0403-11eb-2212-db450c299f35¤code»md"_homework 4, version 1_"¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$48a16c42-0414-11eb-0e0c-bf52bbb0f618„§cell_idÙ$48a16c42-0414-11eb-0e0c-bf52bbb0f618¤codeÙEhint(text) = Markdown.MD(Markdown.Admonition("hint", "Hint", [text]))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$98beb336-0425-11eb-3886-4f8cfd210288„§cell_idÙ$98beb336-0425-11eb-3886-4f8cfd210288¤codeÙWfunction set_status!(agent::Agent, new_status::InfectionStatus) # your code here end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$bb63f3cc-042f-11eb-04ff-a128aec3c378„§cell_idÙ$bb63f3cc-042f-11eb-04ff-a128aec3c378¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$61c00724-0403-11eb-228d-17c11670e5d1„§cell_idÙ$61c00724-0403-11eb-228d-17c11670e5d1¤codeÚ¶md""" ## **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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9cf9080a-04b1-11eb-12a0-17013f2d37f5„§cell_idÙ$9cf9080a-04b1-11eb-12a0-17013f2d37f5¤codeÚŒmd""" 👉 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!")) """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8„§cell_idÙ$4b3ec86c-0419-11eb-26fd-cbbfdf19afa8¤codeÙ[large_experiment = do_experiment(0.25, 10_000) # (10_000 is just 10000 but easier to read)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$61789646-0403-11eb-0042-f3b8308f11ba„§cell_idÙ$61789646-0403-11eb-0042-f3b8308f11ba¤codeÚ.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: """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$39dffa3c-0414-11eb-0197-e72b299e9c63„§cell_idÙ$39dffa3c-0414-11eb-0197-e72b299e9c63¤codeÙ&bigbreak = html"




";¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272„§cell_idÙ$f8e05d94-04ac-11eb-26d4-6f1d2c5ed272¤codeÚif !@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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$88c53208-041d-11eb-3b1e-31b57ba99f05„§cell_idÙ$88c53208-041d-11eb-3b1e-31b57ba99f05¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$887d27fc-04bc-11eb-0ab9-eb95ef9607f8„§cell_idÙ$887d27fc-04bc-11eb-0ab9-eb95ef9607f8¤codeÙŒfunction simulation(N::Integer, T::Integer, infection::AbstractInfection) # your code here return (S=missing, I=missing, R=missing) end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$d57c6a5a-041b-11eb-3ab4-774a2d45a891„§cell_idÙ$d57c6a5a-041b-11eb-3ab4-774a2d45a891¤codeÙÑfunction 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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$12cc2940-0403-11eb-19a7-bb570de58f6f„§cell_idÙ$12cc2940-0403-11eb-19a7-bb570de58f6f¤codeÙ/begin using Pkg Pkg.activate(mktempdir()) end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$76f62d64-0403-11eb-27e2-3de58366b619„§cell_idÙ$76f62d64-0403-11eb-27e2-3de58366b619¤codeÙ 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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$860790fc-0403-11eb-2f2e-355f77dcc7af„§cell_idÙ$860790fc-0403-11eb-2f2e-355f77dcc7af¤codeÚmd""" #### 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: """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$b21475c6-04ac-11eb-1366-f3b5e967402d„§cell_idÙ$b21475c6-04ac-11eb-1366-f3b5e967402d¤codeÙÝmd""" 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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$823364ce-041c-11eb-2467-7ffa4f751527„§cell_idÙ$823364ce-041c-11eb-2467-7ffa4f751527¤codeÙ–function frequencies_plot_with_maximum(data::Vector) base = bar(frequencies(data)) vline!(base, [maximum(data)], label="maximum") return base end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$619c8a10-0403-11eb-2e89-8b0974fb01d0„§cell_idÙ$619c8a10-0403-11eb-2e89-8b0974fb01d0¤codeÚðmd""" ## **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`. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076„§cell_idÙ$38b1aa5a-04cf-11eb-11a2-930741fc9076¤codeÙ–function repeat_simulations(N, T, infection, num_simulations) N = 100 T = 1000 map(1:num_simulations) do _ simulation(N, T, infection) end end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$8dd97820-04a5-11eb-36c0-8f92d4b859a8„§cell_idÙ$8dd97820-04a5-11eb-36c0-8f92d4b859a8¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$df8547b4-0400-11eb-07c6-fb370b61c2b6„§cell_idÙ$df8547b4-0400-11eb-07c6-fb370b61c2b6¤codeÚÁmd""" ## **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)$. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$1d3356c4-0403-11eb-0f48-01b5eb14a585„§cell_idÙ$1d3356c4-0403-11eb-0f48-01b5eb14a585¤codeÙßhtml""" """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$82f2580a-04c8-11eb-1eea-bdb4e50eee3b„§cell_idÙ$82f2580a-04c8-11eb-1eea-bdb4e50eee3b¤code§Agent()¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$86d98d0a-0403-11eb-215b-c58ad721a90b„§cell_idÙ$86d98d0a-0403-11eb-215b-c58ad721a90b¤codeÚ,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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$dc784864-0430-11eb-1478-d1153e017310„§cell_idÙ$dc784864-0430-11eb-1478-d1153e017310¤codeÙømd""" 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: """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3f5e0af8-0414-11eb-34a7-a71e7aaf6443„§cell_idÙ$3f5e0af8-0414-11eb-34a7-a71e7aaf6443¤codeÙÕyays = [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."]¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$3c0528a0-0414-11eb-2f68-a5657ab9e73d„§cell_idÙ$3c0528a0-0414-11eb-2f68-a5657ab9e73d¤codeÙ±not_defined(variable_name) = Markdown.MD(Markdown.Admonition("danger", "Oopsie!", [md"Make sure that you define a variable called **$(Markdown.Code(string(variable_name)))**"]))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$7335de44-042f-11eb-2873-8bceef722432„§cell_idÙ$7335de44-042f-11eb-2873-8bceef722432¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$406aabea-04a5-11eb-06b8-312879457c42„§cell_idÙ$406aabea-04a5-11eb-06b8-312879457c42¤codeÙcfunction interact!(agent::Agent, source::Agent, infection::InfectionRecovery) # your code here end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$c61f35ea-04d6-11eb-2503-17a79f8d0298„§cell_idÙ$c61f35ea-04d6-11eb-2503-17a79f8d0298¤codeÚ4if !@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 end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9cd2bb00-04b1-11eb-1d83-a703907141a7„§cell_idÙ$9cd2bb00-04b1-11eb-1d83-a703907141a7¤codeÙjlet p = plot() for sim in simulations plot!(p, 1:1000, sim.I, alpha=.5, label=nothing) end p end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b„§cell_idÙ$8a28c56e-04b4-11eb-279c-3b4dfb2a9f9b¤codeÙ"bar(frequencies(large_experiment))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$8631a536-0403-11eb-0379-bb2e56927727„§cell_idÙ$8631a536-0403-11eb-0379-bb2e56927727¤codeÚmd""" #### 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.] """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9a13b17c-0403-11eb-024f-9b37e95e211b„§cell_idÙ$9a13b17c-0403-11eb-024f-9b37e95e211b¤codeÚŒmd""" #### 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.) """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$b92f1cec-04ae-11eb-0072-3535d1118494„§cell_idÙ$b92f1cec-04ae-11eb-0072-3535d1118494¤codeÙ.simulation(3, 20, InfectionRecovery(0.9, 0.2))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$9a377b32-0403-11eb-2799-e7e59caa6a45„§cell_idÙ$9a377b32-0403-11eb-2799-e7e59caa6a45¤codeÙ­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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$778ec25c-0403-11eb-3146-1d11c294bb1f„§cell_idÙ$778ec25c-0403-11eb-3146-1d11c294bb1f¤codeÙ”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? """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9611ca24-0403-11eb-3582-b7e3bb243e62„§cell_idÙ$9611ca24-0403-11eb-3582-b7e3bb243e62¤codeÙÊmd""" #### 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.) """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$26f84600-041d-11eb-1856-b12a3e5c1dc7„§cell_idÙ$26f84600-041d-11eb-1856-b12a3e5c1dc7¤code»@enum InfectionStatus S I R¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$1ca7a8c2-041a-11eb-146a-15b8cdeaea72„§cell_idÙ$1ca7a8c2-041a-11eb-146a-15b8cdeaea72¤code½frequencies(small_experiment)¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$190deebc-0424-11eb-19fe-615997093e14„§cell_idÙ$190deebc-0424-11eb-19fe-615997093e14¤codeÚ?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? """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$1a654bdc-0421-11eb-2c38-7d35060e2565„§cell_idÙ$1a654bdc-0421-11eb-2c38-7d35060e2565¤codeÙJstruct InfectionRecovery <: AbstractInfection p_infection p_recovery end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$41cefa68-0414-11eb-3bad-6530360d6f68„§cell_idÙ$41cefa68-0414-11eb-3bad-6530360d6f68¤codeÙ�keep_working(text=md"The answer is not quite right.") = Markdown.MD(Markdown.Admonition("danger", "Keep working on it!", [text]))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$847d0fc2-041d-11eb-2864-79066e223b45„§cell_idÙ$847d0fc2-041d-11eb-2864-79066e223b45¤codeÙ€md""" 👉 Convert `x` to an integer using the `Integer` function. What value does it have? What values do `I` and `R` have? """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$77428072-0403-11eb-0068-81e3728f2ebe„§cell_idÙ$77428072-0403-11eb-0068-81e3728f2ebe¤codeÙ?md""" Let's run an experiment with $p=0.25$ and $N=10,000$. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$9a837b52-0425-11eb-231f-a74405ff6e23„§cell_idÙ$9a837b52-0425-11eb-231f-a74405ff6e23¤codeÙ;function is_susceptible(agent::Agent) return missing end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$0a967f38-0493-11eb-0624-77e40b24d757„§cell_idÙ$0a967f38-0493-11eb-0624-77e40b24d757¤codeÚ˜md""" 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! """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$28db9d98-04ca-11eb-3606-9fb89fa62f36„§cell_idÙ$28db9d98-04ca-11eb-3606-9fb89fa62f36¤codeÙ3@bind run_basic_sir Button("Run simulation again!")¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$8692bf42-0403-11eb-191f-b7d08895274f„§cell_idÙ$8692bf42-0403-11eb-191f-b7d08895274f¤codeÙêmd""" #### 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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$da49710e-0420-11eb-092e-4f1173868738„§cell_idÙ$da49710e-0420-11eb-092e-4f1173868738¤codeÚšmd""" ## **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: """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$7bb8e426-0495-11eb-3a8b-cbbab61a1631„§cell_idÙ$7bb8e426-0495-11eb-3a8b-cbbab61a1631¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$21c50840-0435-11eb-1307-7138ecde0691„§cell_idÙ$21c50840-0435-11eb-1307-7138ecde0691¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$2ade2694-0425-11eb-2fb2-390da43d9695„§cell_idÙ$2ade2694-0425-11eb-2fb2-390da43d9695¤codeÙYfunction step!(agents::Vector{Agent}, infection::AbstractInfection) # your code here end¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$bf6fd176-04cc-11eb-008a-2fb6ff70a9cb„§cell_idÙ$bf6fd176-04cc-11eb-008a-2fb6ff70a9cb¤codeÚ?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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$73047bba-0416-11eb-1047-23e9c3dbde05„§cell_idÙ$73047bba-0416-11eb-1047-23e9c3dbde05¤codeÙ4interpretation_of_p_equals_one = md""" blablabla """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$43e6e856-0414-11eb-19ca-07358aa8b667„§cell_idÙ$43e6e856-0414-11eb-19ca-07358aa8b667¤codeÙ€still_missing(text=md"Replace `missing` with your answer.") = Markdown.MD(Markdown.Admonition("warning", "Here we go!", [text]))¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$2b26dc42-0403-11eb-205f-cd2c23d8cb03„§cell_idÙ$2b26dc42-0403-11eb-205f-cd2c23d8cb03¤code¨bigbreak¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$95c598d4-0403-11eb-2328-0175ed564915„§cell_idÙ$95c598d4-0403-11eb-2328-0175ed564915¤codeÙ�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. """¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÃÙ$1ac4b33a-0435-11eb-36f8-8f3f81ae7844„§cell_idÙ$1ac4b33a-0435-11eb-36f8-8f3f81ae7844¤code ¨metadataƒ©show_logsèdisabled®skip_as_script«code_foldedÂÙ$a8dd5cae-0425-11eb-119c-bfcbf832d695„§cell_idÙ$a8dd5cae-0425-11eb-119c-bfcbf832d695¤codeÙ8function is_infected(agent::Agent) return missing end¨metadataƒ©show_logsèdisabled®skip_as_script«code_folded«notebook_idÙ$efbd3a58-4aa6-11f0-3049-afe95b0c5665«in_temp_dir¨metadata€