Example #1
0
def main(testing=False, accuracy=0.95, rate=0.5):
    TOTAL_POPULATION = 10000000
    US_CASES = 6008588
    People = [Person() for _ in range(TOTAL_POPULATION)]
    People[0].getSick()
    weeks = 0
    totalInfected = []
    totalDead = []
    currentlyInfected = []
    while Person.currentlyInfected > 0 and Person.totalInfected < TOTAL_POPULATION:
        People = Spread.forward_one_week(People, testing, accuracy, rate)
        weeks += 1
        print("***** After {} weeks the stats are *****".format(weeks))
        print("Total people infected:", Person.totalInfected)
        print("Currently Infected:", Person.currentlyInfected)
        print("Total dead:", Person.totalDead)
        print()
        totalInfected.append(Person.totalInfected)
        totalDead.append(Person.totalDead)
        currentlyInfected.append(Person.currentlyInfected)
    plt.figure()
    plt.plot(range(weeks), totalInfected, range(weeks), totalDead,
             range(weeks), currentlyInfected)
    plt.legend(["Total Infected", "Total Dead", "Currently Infected"])
    plt.yscale("log")
    plt.xlabel("Weeks")
    plt.savefig("infection.png")
Example #2
0
def main(testing, accuracy, rate):
    TOTAL_POPULATION = 300000000
    US_CASES = 6008588
    People = []
    PatientZero = Person()
    People.append(PatientZero)
    weeks = 0
    while Person.totalInfected < US_CASES:

        People = Spread.forward_one_week(People, testing, accuracy, rate)
        weeks += 1
        print("***** After {} weeks the stats are *****".format(weeks))
        print("Total people infected:", Person.totalInfected)
        print("Currently Infected:", Person.currentlyInfected)
        print("Total dead:", Person.totalDead)
        assert (Person.currentlyInfected == len(People))
        print()