# On A Clockwork Contagion

During the recent epidemic, my fellow students and I had plenty of time upon our hands due to the closure of the taverns, theatres and gambling houses at which we would typically while away our evenings and the Dean's subsequent edict restricting us to halls. We naturally set to thinking upon the nature of the disease's transmission and, once the Dean relaxed our confinement, we returned to our college determined to employ Professor B------'s incredible mathematical machine[1] to investigate the probabilistic nature of contagion.

### A First Model Of Infections

We commenced our experimentations with simplistic model comprised of a population of $$n$$ individuals, each of whom initiates contact with another $$k$$ times daily at random, and that an infectious person has a probability $$p$$ of passing it on during an encounter with an uninfected person who would thereafter become infectious upon the following day. We put together deck 1 to exercise this model for one hundred days, charting the total number of infected each day for a population of ten thousand souls, of whom but one is infectious at the outset, eight initiated contacts per person per day and a one percent chance of transmission

Deck 1: Total Infected By Day

and deck 2 to chart the number of people newly infected each day.

Deck 2: Newly Infected By Day

Since our model assumes that contacts are independent of one another, if there are $$i$$ infectious folk upon a given day then the number $$K^\rightarrow$$ of them with whom an uninfected person initiates contact is governed by the binomial distribution with $$k$$ experiments, each with a $$\frac{i}{n-1}$$ chance of success, having a probability mass function, or PMF, of
$\Pr\left(K^\rightarrow = k^\rightarrow\right) = p_{k,\frac{i}{n-1}}\left(k^\rightarrow\right) = \begin{cases} {}^k C_{k^\rightarrow} \times \left(\frac{i}{n-1}\right)^{k^\rightarrow} \times \left(\frac{n-1-i}{n-1}\right)^{k-k^\rightarrow} & 0 \leqslant k^\rightarrow \leqslant k\\ 0 & \text{otherwise} \end{cases}$
where $${}^nC_r$$ is the combination which counts the number of ways that $$r$$ items can be chosen from $$n$$ when the order in which they are picked is of no significance.
Similarly, there are $$i \times k$$ contacts initiated by the infectious, each of which has of probability of $$\frac{1}{n-1}$$ of being with that uninfected fellow, and therefore the number of times $$K^\leftarrow$$ that they are so contacted has the PMF
$\Pr\left(K^\leftarrow = k^\leftarrow\right) = p_{i \times k,\frac{1}{n-1}}\left(k^\leftarrow\right) = \begin{cases} {}^{i \times k} C_{k^\leftarrow} \times \left(\frac{1}{n-1}\right)^{k^\leftarrow} \times \left(\frac{n-2}{n-1}\right)^{i \times k - k^\leftarrow} & 0 \leqslant k^\leftarrow \leqslant i \times k\\ 0 & \text{otherwise} \end{cases}$
The likelihood that their total number of infectious contacts equals $$k^\leftrightarrow$$ is consequently given by the convolution
$\Pr\left(K^\leftrightarrow = k^\leftrightarrow\right) = p^\leftrightarrow\left(k^\leftrightarrow\right) = \sum_{k^\rightarrow=0}^k p_{k,\frac{i}{n-1}}\left(k^\rightarrow\right) \times p_{i \times k,\frac{1}{n-1}}\left(k^\leftrightarrow-k^\rightarrow\right)$
where $$\sum$$ is the summation sign. Upon $$k^\leftrightarrow$$ interactions with contagious people, an uninfected person has a chance of $$(1-p)^{k^\leftrightarrow}$$ of remaining so and the probability that they will fail to escape infection over the course of the day is therefore
$p^+ = 1 - \sum_{k^\leftrightarrow=0}^{i \times k + k} p^\leftrightarrow\left(k^\leftrightarrow\right) \times (1-p)^{k^\leftrightarrow}$
Since there are $$n-i$$ uninfected, the number of novel cases $$K^+$$ is distributed as
$\Pr\left(K^+ = k^+\right) = p_{n-i,p^+}\left(k^+\right) = \begin{cases} {}^{n-i} C_{k^+} \times {p^+}^{k^+} \times \left(1-p^+\right)^{n-i-k^+} & 0 \leqslant k^+ \leqslant n-i\\ 0 & \text{otherwise} \end{cases}$
and, noting that we can ignore those circumstances in which $$i \times k$$ is greater than $$n$$, we have constructed deck 3 to show how it evolves as the number of infected people increases, with each bar showing the probability of a range of values using the cumulative distribution function, or CDF, to figure them with
$\Pr\left(k^+_0 < K^+ \leqslant k^+_1\right) = P_{n-i,p^+}\left(k^+_1\right) - P_{n-i,p^+}\left(k^+_0\right)$

Deck 3: The Distribution Of Novel Cases

To assure ourselves that these supposed daily distributions of infections are indeed the consequence of our model we assembled deck 4 to accumulate random observations from them.

Deck 4: Binomial Infections

Having run decks 2 and 4 some several times, my fellow students and I are confident that, upon the average, they exhibit the same behaviour.

### Further Simplifications

Lamentably, the randomness inherent in our model precludes drawing firm conclusions and so we sought to simplify it by putting each and every one of their masses at their means. Noting that
\begin{align*} K &\sim Binom(n, p)\\ E[K] &= n \times p \end{align*}
where $$\sim$$ means drawn from and $$E\left[K\right]$$ is the expected value of $$K$$, we have
$E[K^\leftrightarrow] = E[K^\rightarrow + K^\leftarrow] = E[K^\rightarrow] + E[K^\leftarrow] = k \times \frac{i}{n-1} + i \times k \times \frac{1}{n-1} = \frac{2 \times i \times k}{n-1}$
and consequently
$p^+ \approx 1 - (1-p)^\frac{2 \times i \times k}{n-1} = 1 - \left((1-p)^\frac{2 \times k}{n-1}\right)^i$
Defining
$\hat{p} = (1-p)^\frac{2 \times k}{n-1}$
gives us the first order approximation
$E\left[K^+\right] = (n-i) \times p^+ \approx (n-i) \times \left(1 - \hat{p}^i\right)$
as charted by deck 5.

Deck 5: The First Order Approximation

That this doesn't look too dissimilar to the most frequent results of our simulations lent us some confidence that this was not too unreasonable a simplification.

Having been confined to dorms we were most curious as to how such measures might have limited the rate of infection and so we built deck 6 to track it daily for varying levels of interpersonal contact.

Deck 6: The Effect Of Contacts

As crude as our model unquestionably is, this was at least indicative that the dean's command should have reduced the rate of transmission and spared our matron from a deluge of convalescents!

### A Measure Of Variability

We can express the number of infected as a proportion of the population with
$i = r \times n$
yielding
$p^+ \approx 1 - (1-p)^\frac{2 \times i \times k}{n-1} = 1 - (1-p)^\frac{2 \times r \times n \times k}{n-1} \approx 1 - (1-p)^{2 \times r \times k}$
Further defining
$\hat{p} = (1-p)^{2 \times k}$
we have
$E\left[K^+\right] \approx (n-r \times n) \times \left(1 - \hat{p}^r\right) = n \times (1-r) \times \left(1 - \hat{p}^r\right)$
and so the expected daily increment of $$\Delta r$$ in that proportion is
$\mu_{\Delta r} = E\left[\Delta r\right] = E\left[\frac{K^+}{n}\right] \approx (1-r) \times \left(1 - \hat{p}^r\right)$
Now the variance of the binomial distribution for $$n$$ trials with a probability of success of $$p$$ is $$n \times p \times (1-p)$$ and so
\begin{align*} \sigma^2_{\Delta r} &= E\left[\left(\Delta r - E\left[\Delta r\right]\right)^{\,2}\right] = E\left[\left(\frac{K^+}{n} - E\left[\frac{K^+}{n}\right]\right)^2\right]\\ &= \frac{E\left[\left(K^+ - E\left[K^+\right]\right)^{\,2}\right]}{n^2} \approx \frac{(n-r \times n) \times \left(1 - \hat{p}^r\right) \times \hat{p}^r}{n^2}\\ &= \frac{1-r}{n} \times \left(1 - \hat{p}^r\right) \times \hat{p}^r \end{align*}
Noting that ninety five percent of the mass of the normal distribution lies within two standard deviations of the mean we assembled deck 7 to track reasonable bounds upon the rate of infection if it proceeds according to the mean, plotting the lower in red and the upper in green.

Deck 7: Daily Bounds Of Infection

Furthermore, deck 8 demonstrates how such bounds are affected by the number of contacts.

Deck 8: Reducing Contacts

Whilst these give some indication of the variability of our model's results, they fail to entirely reflect its significance. Specifically, by following the mean they ignore the cumulative effect of deviations from it. To rectify this deck 9 consistently steps one standard deviation away from the mean, both above and beneath, once the proportion of infected crosses a threshold of r0.

Deck 9: Cumulative Deviations

Quite evidently the cumulative impact of variation is profound and so we fashioned deck 10 to give some notion of the relationship between it and the number of contacts.

Deck 10: Cumulative Deviations For Reducing Contacts

Remarkably, reducing the peak rate of infection comes at the expense of increasing the uncertainty of when it will occur! This is most certainly an effect that my fellow students and I are keen to examine further when we have time to improve the veracity of our model and I shall be sure to report upon it once we have.
$$\Box$$

### References

[1] On An Age Of Wonders, www.thusspakeak.com, 2014.