## Gillespie simulation

While synchronous simulation is straightforward to understand and code, we can manipulate the mathematical description of the simulation probabilities to generate a much more efficient simulation dynamics, known as *stochastic* or *Gillespie* simulation. This is far more efficient, more statistically exact, and is generally the method used where possible.

(This is a chapter from Complex networks, complex processes.)

## Synchronous simulation

The simplest way to simulate an epidemic from a computing perspective is to adopt a discrete time model. We tie this together with our compartmented models from earlier to create a simulator for SIR.

(This is a chapter from Complex networks, complex processes.)

## Epidemic simulation

Before we go any further, let’s pause to think about the general theme of computer simulation. This is a huge topic, but some of the common themes, ideas, and terms are essential to understanding how to simulate an epidemic — and equally importantly, to make some of the decisions that need to be made.

(This is a chapter from Complex networks, complex processes.)

## Coding a compartmented model

Having moved from continuous to discrete views of compartmented disease models, we now need to create code so we can simulate such diseases over a network. There are lots of possible compartmented models, so — rather than develop each from scratch — we make use of a Python library the gives us a framework for doing so. This has the advantages that the code we develop can be run under different simulation regimes if required, and can also be run at scale.

(This is a chapter from Complex networks, complex processes.)

## From continuous to networked compartmented models

Let’s now return to the compartmented models of disease we developed earlier. These were continuous models, described using calculus. Networks, by contrast, are discrete structures consisting of nodes and edges. We therefore need to develop a way to think about the continuous model in a discrete way appropriate to being applied as a process over a network..

(This is a chapter from Complex networks, complex processes.)

## The components of an ER network

ER networks have a strange property: even a small number of edges, distributed randomly, can lead to a connected structure with very high probability — the so-called “giant” component. Studying this effect brings up the notion of a critical threshold and a phase change, which can be calculated both mathematically and in simulation.

(This is a chapter from Complex networks, complex processes.)

## Concepts: connectivity, components, and cliques

If it’s possible to build a path between any pair of nodes in a network, then this has implications for navigation and how processes work. Sometimes networks are connected; sometimes they are composed of disconnected components; and sometimes somewhere in between.

(This is a chapter from Complex networks, complex processes.)

## The mathematics of ER networks

Because Erdős-Rényi networks have a very simple and regular generation process, it’s reasonable to ask whether we can do better than numerical studies when trying to find its degree distribution, mean degree, and the like. And indeed we can.

(This is a chapter from Complex networks, complex processes.)

## Erdős-Rényi networks

Let’s leave epidemic spreading for a little while to return to the static structure of networks, and look at perhaps the most common class of network, the *Erdős-Rényi* or* ER network*. These networks are incredibly simple to describe, incredibly simple to build and simulate – and incredibly useful as at least first-attempt network models for a range of processes. We’ll also run up against the limitations of animation for presenting networks.

(This is a chapter from Complex networks, complex processes.)

## Compartmented models of disease

When modelling diseases computationally we need to step back from the biological complexity somewhat, and this leads to a set of approaches called *compartmented models*. A disease progresses through a set of stages, modelled as compartments: at any point, each individual sits in a particular compartment and the disease evolves by people moving between the compartments as their disease progresses. Classically these models are studied using differential equations, and it’s useful to understand this before seeing how networks provide a more reliable setting for the same models.

(This is a chapter from Complex networks, complex processes.)