6
$\begingroup$

I'd like to try teaching an online lesson to high school CS students on modeling the spread of a virus. Ideally it would be something that could be coded in a spreadsheet, Code.Org's Game Lab or App Lab, or in Unity.

I'd appreciate any pointers to how to get started – what are the important underlying concepts for students to understand, what are the minimal skills they would need to produce a "satisfying" model, what are the key variables that a model should incorporate?

Suggestions about how to get my own head around the field, or videos of modelers talking about their work, or articles would all be welcome.

Update:

First: many thanks for the great and concrete suggestions coming in, they really help.

Second: this is, or could be, a collaboration across disciplines – math, CS, health, social studies, and art / graphic design all have a role in developing and presenting a good model.

Third: clearly, in these times, this is a distance learning question as well.

$\endgroup$
  • 1
    $\begingroup$ I love this idea. I'm going to see if I can figure out a way to steal it in my own classroom :) Oh, and I sent the question to someone who may have some interesting things to add about the actual mathematics of the modeling! $\endgroup$ – Ben I. Mar 27 at 21:07
  • 1
    $\begingroup$ I highly recommend the Numberphile video youtube.com/watch?v=k6nLfCbAzgo where they're modeling the SIR model in Geogebra. $\endgroup$ – Guntram Blohm Mar 28 at 15:55
4
$\begingroup$

I teach a Mathematical Modeling elective at the high school where Ben I. and I teach. I would love to do an in-depth object-based model using programming with my students, but generally speaking I don't have the ability to assume that all of my students know how to code. Most of them, but not all.

So, my solution is typically to use spreadsheets and the standard differential equation models to deal with disease spread. One of the simplest models is what's called the SIR model, which is an example of a compartmental model . Because these mathematical models are focused on total numbers in each category of the population and not on individuals, a spreadsheet is sufficient to see what happens.

Typically, for a three-compartment model, you need a minimum of three columns/variables to track overall counts. I would strongly recommend a fourth to keep track of time, and if you want, a fifth to keep track of deaths. You will need initial values for each quantity and parameters that are used to keep track of movement from one category to another.

For example, if I use the F1 cell to store the virulence parameter of the disease, F2 to store the recovery rate and F3 to store the lethality parameter, then we can build the model. I also recommend including a time-step parameter somewhere, let's say in F4. This will give you one control that will help to avoid calculation nonsense if some of your numbers are too large.

          A         B         C         D          E         F
1         Time      Suscept   Infected  Recovered  Dead      virulence (1/1000000)
2         0         10000     1         0          0         recovery (1/100)
3         A2+F$4    B formula C formula D formula  E formula lethality (1/1000)
4         c  o  p  y     t  h  e     f  o  r  m  u  l  a  s  time step (0.1)

Where the B formula in B3 is =B2-F$4*(F$1*B2*C2)
Where the C forumla in C3 is =C2+F$4*(F$1*B2*C2-F$2*C2-F$3*C2)
Where the D formula in D3 is =D2+F$4*(F$2*C2)
Where the E formula in E3 is =E2+F$4*(F$3*C2)

Drag those formulas down as far as you want and make a scatter plot with all of the variable columns highlighted and you have a basic differential equation epidemiological model. It can be used to convey the very important fact that the most dangerous diseases to a population are the ones which are highly contagious, and not the ones that will kill you quickly, and that the ones which are highly lethal are actually safer for the population.

If you want other lessons from this, you're going to need to delve into the more complicated epidemiological models that demonstrate the effects of things like imposed quarantine, self-quarantine behavior, gathering of sick people at hospitals, vaccination, re-infection, or multi-stage diseases.

| improve this answer | |
$\endgroup$
4
$\begingroup$

Here are two resources that might be appropriate, but neither is a spreadsheet model.

The first is a resource called Contagion that has just been created for the Greenfoot Java system (IDE plus resources). You can find it at the Greenroom.

The second is a section on Simulation in a book called Polymorphism Companion. The book is actually the second volume of a pair and you might need the first one also Polymorphism: As It Is Played. They are both about using polymorphism, especially in Java.

Both of these resources model a disease spreading through a population. They have various parameters you can set to get some realistic(ish) results. Think of a Disease interface, for example, with diseases of various characteristics implemented via polymorphism.

| improve this answer | |
$\endgroup$
3
$\begingroup$

You probably could adapt A. K. Dewdney’s “Sharks and Fishes” programming challenge from his old Scientific American column (https://www.cs.mcgill.ca/~carl/fishnsharks.html). Here’s another example of it being used in education https://people.eecs.berkeley.edu/~jrs/61bf06/hw/pj1/readme

In this case, you could just have one subject type (people) but maintain states for them with pixel colors :

  • White: Uninfected
  • Yellow: Infected but asymptomatic (optional)
  • Red: Infected
  • Green: Recovered (immune)
  • Black: Deceased

You can make the people like sharks in that they move around (unless sick or deceased) and have a chance of infecting others within a certain distance.

Then you can study how changing parameters affects the spread:

  • Population total/density
  • Probability of infection
  • Range of contact for infection
  • Length of illness before recovery/mortality
  • Chance of recovery vs mortality
  • Social Behavior: people/sharks move towards each other, vs moving away from each other

Initially, it might be easier to just start with the Sharks and Fishes problems and when completed, morph it into a mobile infection problem.

Alternatively, you could start with a non-mobile problem (ie., people don't move), just make sure that in the initial distribution of people, everyone is adjacent to at least one other person.


I had missed the part about doing it in a spreadsheet. If you mean just doing it with spreadsheet formulas, then you'll probably run into a problem with circular references. In Excel I think that you can use either the Optimization tools or else advanced settings to get around that, but its tricky.

In Excel for Windows (but not the other OS's) you can use VBA to implement a simple model like this. I did it decades ago, but I don't have any of those with me now.

If a full blown VBA project is too much, then you could also do it with just sheet formulas and one or two simple VBA macros. Let me know if you want and I can explain how.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Welcome to the site.. Come back for more. $\endgroup$ – Buffy Mar 28 at 15:21
  • 2
    $\begingroup$ It's not especially relevant here, but the late professor Pat Doyle once wrote a paper: An In-Eating Cannibalistic Society Could Be Stable. It used the standard predator-prey model and unified the predator and prey variables. $\endgroup$ – Buffy Mar 28 at 15:40
  • $\begingroup$ Added stuff about using spreadsheets for this. $\endgroup$ – RBarryYoung Mar 30 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.