Home | | Mathematics | | Share This Page |

Coronavirus Math

Using Calculus to analyze a pandemic

— P. Lutus — Message Page —

Copyright © 2020, P. Lutus

First publication: 04.05.2020

Most recent update:

Overview | The Pandemic Explorer | The S-I-R ModelSequestration Feature | Policy Implications | Python Resources

Notes

(double-click any word to see its definition)

Overview

Readers may want to see this relevant video by the author.

Albert Einstein once said, "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality". In my experience I find this pretty accurate, but even though math cannot duplicate reality, if well-managed it can produce a reasonable facsimile.

This article uses a differential equation to model the evolution of a pandemic such as the Coronavirus. This, and similar equations, are basic tools in epidemiology — they're used to plan defensive strategies and shape public policy.

This is a textbook example where the public relies on governmental guidance, the government relies on scientists and scientific methods, and the scientists rely on mathematics — the mathematics this article describes.

In ordinary circumstances, citizens have access to "what" — what policy, what rules, what precautions and prohibitions. In this article, I show the "why" behind the "what", the reasoning behind the policies we've chosen to fight the Coronavirus. We know we must stay at home and avoid close contact with others, but most people don't fully understand the reasons. This article explains policy in-depth, and more, it allows the reader to use an interactive mathematical tool to experiment with different assumptions and pose "what-if" questions.

Let's get started.

The Pandemic Explorer

Legend:Adjust the controls to change simulation values, full explanation below.

Pandemic Time Series

100% 80% 60% 40% 20% 0% Days: $R_0$ 0 $R_1$ 0 Sequestration Zone display Chart grid$S_s$ 0 $S_e$ 0 $S_p$ 0

`Susceptible (S):`

`Infectious (I):`

`Recovered/removed (R):`

The S-I-R Model

This section describes a differential equation (the S-I-R model) the above application uses, that can be employed to model infections in populations. It processes these parameters:

- $S$, the susceptible population, those who are not yet infected.
- $I$, the infectious population, those who are infected and able to infect others.
- $R$, the recovered/removed population, those who have already been infected, are no longer infectious, and have either recovered or died.
- $R_0$, the rate at which infectious individuals infect others over time.
- $R_1$, the rate at which infected individuals remove themselves over time, either by recovering or dying.
- $t$, time, the system's independent variable.
The equation's terms are:

\begin{equation} \frac{dS}{dt} = -S I R_0 \end{equation} \begin{equation} \frac{dI}{dt} = S I R_0 - R_1 I \end{equation} \begin{equation} \frac{dR}{dt} = R_1 I \end{equation}Because this equation must be processed numerically, it's necessary to evaluate an outcome for a particular time by computing intermediate results on the interval between time zero and the time of interest. In preparation for this numerical evaluation, the system's dependent variables are assigned these values at time zero:

- $S$, susceptible, set to 1 ("normalized") in this model (reason given below).
- $I$, infectious, set to 0.01. This is patient zero.
- $R$, recovered/removed, set to 0.
- $R_0$, time rate of infection, a user-selected value in the range [0..10].
- $R_1$, time rate of recovery/removal, a user-selected value in the range [0..1].
For simplicity and ease of application I use a normalized version of this equation, one in which:

\begin{equation} S(t) + I(t) + R(t) = 1 \end{equation}and:

\begin{equation} \frac{dS}{dt} + \frac{dI}{dt} + \frac{dR}{dt} = 0 \end{equation}Because this system is normalized, one acquires a specific forecast by multiplying its results by the population size.

The meaning of equation (4) above is that a population is the sum of S, I, and R, meaning all population members are accounted for and belong to one of the three groups. It also implies that the only way to eliminate infection is to set $R_0$ to zero. Without this condition and with sufficient time, everyone will become infected and transition to the recovered/removed ($R$) group.

This is a typical real-world differential equation, meaning the degree to which it accurately models reality is the same degree to which it cannot be expressed in closed form, meaning it must be solved numerically.

Sequestration Feature

Recent versions of this application include an analysis feature that examines the effect of sequestration (in this context meaning a percentage of the population isolated from interaction with others). This feature allows the user to set a starting and ending day for sequestration, and a percentage of the population that would be sequestered.

The purpose of this feature is to permit evaluation of the effect of sequestration, to allow the user to set up what-if scenarios, test outcomes with different parameters.

To activate this feature, users should click the "Sequestration" check-box in the application user interface. When the feature has been activated, a shaded rectangle appears in the display to show the dimensions of the user-defined sequestration interval.

The sequestration user controls are:

- Start day
- End day
- Percentage (of population or of effectiveness).
To use this feature, select a start and end day for the sequestration, and a percentage. The percentage entry can be thought of as a percentage of the population put into sequestration, or as a measure of the effectiveness of the sequestration — the effect is the same.

This feature changes the normal S-I-R equations — a sequestration term (shown as $q$ below) is included that modifies each appearance of the $R_0$ rate-of-infection term:

\begin{equation} \frac{dS}{dt} = -S I R_0 q \end{equation} \begin{equation} \frac{dI}{dt} = S I R_0 q - R_1 I \end{equation} \begin{equation} \frac{dR}{dt} = R_1 I \end{equation}Although the sequestration effectiveness term is expressed as a percentage in the user interface, in equations 6 and 7 it has a value in the range [1..0], such that if 100% of the population is sequestered, the $q$ value is 0 and new infections are prevented for the duration of the user-selected interval.

When enabled, the sequestration feature shows that new infections are slowed (for sequesters < 100%) or stopped (for the 100% case), but sequestered individuals who were already infected continue to transition from the $I$ (infectious) group to the $R$ (recovered/removed) group over time.

Tests using this feature lead to what may seem a surprising conclusion — sequestration can only postpone public infection, it cannot prevent it. In most scenarios, adding a sequestration interval only postpones an infection peak, and a new surge of infections is likely as the sequestration interval ends and people resume their normal lives.

This simulation also shows that, in the long run, unless a vaccine is developed, everyone becomes infected.

If a vaccine is possible and if its development timeline is known, then sequestration becomes even more important, because this policy may be able to postpone an infection peak past the point at which the susceptible population can be immunized

en masse.

Policy Implications

This exploration and treatment shows why the stay-at-home and social-distancing policies has been put in place. The most pessimistic but realistic assumption is that a vaccine won't become available for some time (if ever), therefore the best strategy to maximize survival is to act in a way that doesn't overwhelm the health care system.

The present policy doesn't keep people from becoming infected, it only slows the rate at which people move from the $S$ (susceptible) to $I$ (infected) groups, so that the total number of infected people at any time is within the capacity of the health care system. The reasoning is that with proper care, the mortality rate may be small, but if the health care system breaks down, the mortality rate could be much higher than it would be if proper care were available.

A secondary reason to slow the infection rate (i.e. a small $R_0$ in the above mathematical treatment) is in anticipation of a vaccine. If a vaccine is developed and proves safe, it may be possible to immunize the remaining members of the $S$ (susceptible) group

beforethey become infected. This is another reason to slow the rate at which people become infected.For both these reasons — to keep from overwhelming the health care system and to minimize the infection rate while a vaccine is developed — the stay-at-home, no-nonessential-travel, social-distancing measures are the best approach to minimizing the harm this virus can do.

Until recently, few public policies have been guided by mathematics, but this pandemic is a perfect candidate for a quantitative what-if analysis using easily understood equations.

I hope this mathematical application and analysis proves useful.

Update 2020.07.09:Since this page was first published and predicted a surge in infections as sequestration ended, that prediction has come true worldwide. This outcome shouldn't surprise anyone — all responsible health researchers made the same advance prediction.

To date Covid-19 policy has been steered by politics, not science, and as long as that remains true, we can look forward to more "unexpected" outcomes.

Python Resources

I originally created the graphs and animations for this YouTube video, and as a code template for this Web page, using Python scripts like this one:

- cv_model.py, creates either a single user-customizable graphic similar to the above display, or a user-specified duration HD (1920x1080) video that animates a range of user-defined values and their results.
The script assumes (a) a Linux environment, (b) the presence of Python 3, and (c) the presence of

`ffmpeg`

to convert a series of still images into a video.

Notes

This application has evolved quite rapidly since its basic algorithm was imported from Python, and the sequestration feature was developed and tested in JavaScript and back-ported to Python (scripts above). It is now much easier to test assumptions and perform experiments than in the earlier Python incarnation.

Local StorageThis application now saves user entries between visits, so visitors can abandon a work session and the interface will preserve their entries for the next visit. This is implemented using a relatively new browser feature called local storage —

cookies are not used— and the storage is purely local, no data is transmitted anywhere else or used in any way.

Revisions

- 2020.07.09 changed order of plotted zones to (bottom to top) I:R:S, and made a sequestration interval the default setting.

Home | | Mathematics | | Share This Page |