Published
Edited
May 14, 2020
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
// [Note] There is support in this notebook for setting a certain portion of the population as workers and assigning them workplaces, but that isn't currently being used since the current version of the game includes going to school and work as a subset of "large gatherings."
ageDistribution = [{range: '0-19', portionOfPopInThisRange: 0.26, susceptibility: 0.003, asymptomaticPortion: 0.50 , hospitalIfSymptomatic: 0.02, employedProportion: 0.95}, // employed proportion includes kids going to 'school' -- though it's not currently being used in the game.
{range: '20-39', portionOfPopInThisRange: 0.27, susceptibility: 0.008, asymptomaticPortion: 0.4 , hospitalIfSymptomatic: 0.16, employedProportion: 0.8},
{range: '40-59', portionOfPopInThisRange: 0.26, susceptibility: 0.010, asymptomaticPortion: 0.3 , hospitalIfSymptomatic: 0.25, employedProportion: 0.8},
{range: '60-79', portionOfPopInThisRange: 0.17, susceptibility: 0.025, asymptomaticPortion: 0.2, hospitalIfSymptomatic: 0.37, employedProportion: 0.5},
{range: '80+', portionOfPopInThisRange: 0.04, susceptibility: 0.035, asymptomaticPortion: 0.15, hospitalIfSymptomatic: 0.50, employedProportion: 0.05}
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
susceptibleInOtherNeighborhoods = otherNeighborhoodsVisited * destinationsInNeighborhood * peoplePerDestination
Insert cell
susceptibleVisitingInfectorsNeighborhood = susceptibleInOtherNeighborhoods
Insert cell
susceptibleInNeighborhood = destinationsInNeighborhood * peoplePerDestination - 1 // -1 to remove the infector from the count
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
decisionsPerWeek = ({'food':3,'exercise':5, 'small gathering':2, 'large gathering':5, 'work':0})
Insert cell
exposureByType = ({'food':0.3, 'exercise':0.1, 'small gathering':1, 'large gathering':0.3, 'work':1.5})
Insert cell
Insert cell
Insert cell
numLargeGatheringDestinations = function() {return _.random(1, 5)}
Insert cell
Insert cell
numPeopleInHouseFormula = function(){ return _.random(1, 5)}
Insert cell
md`### Disease Parameters`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
daysWhileInfectious = daysPresymptomaticInfectious+daysSymtpomaticInfectious
Insert cell
Insert cell
Insert cell
Insert cell
numInfectors = 1000
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {slider,select} from "@jashkenas/inputs"
Insert cell
d3 = require("d3@5")
Insert cell
_ = require("lodash")
Insert cell
roundProb = function(x) {return Math.floor(x) + (Math.random() < (x - Math.floor(x))) }
Insert cell
consoleLogging = 0 // if this changes to 1 there's a whole lot of console-logging in the infectionsByInfector cell -- which can get slow when 1K infectors. When I wanted to inspect the console log I'd set numInfectors to 7-10 first.
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more