Here's a simple epidemic simulator in Swift using a basic model that assumes the following:
infectionRate
property.recoveryTime
property.main.swift1785 chars72 lines
This simulator sets up a population of n
individuals with given infectionRate
and recoveryTime
properties for each individual. These can be calibrated to model different epidemics. Then, we run the simulation by stepping through each day and checking whether infected individuals infect others. We stop the simulation when there are no more infected individuals. The output of the simulator is the number of people infected each day and the total number of days until the epidemic is contained.
gistlibby LogSnag