Skip to content

Instantly share code, notes, and snippets.

@obiwankenoobi
Last active February 24, 2020 22:24
Show Gist options
  • Save obiwankenoobi/23c659521eb5ecfedbc265d71d1ebc08 to your computer and use it in GitHub Desktop.
Save obiwankenoobi/23c659521eb5ecfedbc265d71d1ebc08 to your computer and use it in GitHub Desktop.
Coronavirus model
function simpleCoronaModel() {
let numOfSickPeople = 1
let numberOfDeaths = 0
let days = 0
const infectionPerDay = 1.165
const period = 100
const healingRate = 1 / 14
const percentageOfSurvivors = 0.97
while (days < period) {
numOfSickPeople *= infectionPerDay
numOfSickPeople -= (healingRate * infectionPerDay)
days++
}
numberOfDeaths = numOfSickPeople - (numOfSickPeople * percentageOfSurvivors)
return { numberOfDeaths, numOfSickPeople }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment