# How Epidemics Spread 1, Exercise 2: reading the boarding-school curve # Using the 14 daily in-bed counts (763 boys, 512 cases; data from the # 'outbreaks' R package, originally read off a figure): # (a) the day-to-day ratio of the in-bed count for days 1 to 6 # (b) the day with the largest rise, and the day with the largest fall # (c) the days on which more than half the peak number were in bed # (d) the day on which most boys were in convalescence in_bed = [3, 8, 26, 76, 225, 298, 258, 233, 189, 128, 68, 29, 14, 4] convalescent = [0, 0, 0, 0, 9, 17, 105, 162, 176, 166, 150, 85, 47, 20] ratios = [round(in_bed[i + 1] / in_bed[i], 2) for i in range(5)] print("ratios days 1-6:", ratios) changes = [in_bed[i + 1] - in_bed[i] for i in range(13)] print("largest rise: day", changes.index(max(changes)) + 2, "(+%d)" % max(changes)) print("largest fall: day", changes.index(min(changes)) + 2, "(%d)" % min(changes)) half = max(in_bed) / 2 days_over = [d for d, n in enumerate(in_bed, start=1) if n > half] print("days above half the peak:", days_over[0], "to", days_over[-1], f"({len(days_over)} days)") top = max(convalescent) print("convalescence peaks on day", convalescent.index(top) + 1, "with", top) # Output when run: # ratios days 1-6: [2.67, 3.25, 2.92, 2.96, 1.32] # largest rise: day 5 (+149) # largest fall: day 10 (-61) # days above half the peak: 5 to 9 (5 days) # convalescence peaks on day 9 with 176