Member-only story

Jim Clarke
4 min readNov 18, 2020

--

Simple Epidemic Modeling in GO

My last article detailed a “Simple Epidemic Modeling in Python”. After waiting 5 minutes and 16 seconds for the model to work through an epidemic in a population of 1 million people, I decided to write the model in GO. I’ve been interested in GO for awhile and tested it about 4 years ago, time for a deeper dive.

TLDR: GO took 6 seconds to run a million people through the epidemic.

As a programmer who cut his teeth in embedded programming using C. (My K&R is dated 1978.) I find GO natural and I like having my {} back. But disappointingly GO doesn’t use ; as a line ending.

I did like having command line back. Once the program is compiled I can direct the program output to a csv file and import to excel and graph the data.

eip_go > epidemicout.csv

Program details: My model follows the SIR or Susceptibility Infected Recovered Model. Wikipedia does a great explaining the SIR concept and math. This is a discrete implementation, so you don’t need to be great with differential equations to be an epidemic modeler.

The heart of the program are the lists: sick and dayssick. The length of these lists are the size of the population. The persons health status is stored in the sick list. 0= not sick or susceptible, 1=sick, 2=was sick and recovered.

--

--

Jim Clarke
Jim Clarke

Written by Jim Clarke

Electronics Engineer with Masters in Physics and Masters in Operations Research.

No responses yet