# How Epidemics Spread 4, Exercise 2: a vaccine that is too weak # Exercise 2: a vaccine that is too weak (all values assumed). r0, E, gamma, population, dt = 6.0, 0.8, 0.2, 10_000, 0.05 beta = r0 * gamma print(f"threshold {1 - 1 / r0:.1%} is above E = {E:.0%}, so full coverage cannot stop spread") def run(coverage, effectiveness): protected = coverage * effectiveness * population S, I = population - protected - 1.0, 1.0 while I >= 0.01: new_inf = beta * S * I / population * dt S -= new_inf I += new_inf - gamma * I * dt return (population - protected - S) / population print("coverage share of everyone infected") for coverage in [0.5, 0.8, 1.0]: print(f"{coverage:8.0%} {run(coverage, E):20.1%}") needed = 1 - 1 / r0 print(f"A vaccine with E = {needed + 0.05:.1%} at 100% coverage:") print(f"{1.0:8.0%} {run(1.0, needed + 0.05):20.1%}") # Output when run: # threshold 83.3% is above E = 80%, so full coverage cannot stop spread # coverage share of everyone infected # 50% 58.2% # 80% 30.1% # 100% 6.3% # A vaccine with E = 88.3% at 100% coverage: # 100% 0.0%