SIR Epidemiology Model

We use the Bayesian paradigm in order to find the parameters of the SIR model.

The uncertainty in the parameters is quantified by sampling the conditional distribution of the parameters on available data using Korali.

We use data from infected people on coronavirus in Switzerland. The data are obtained from here.

The data at time, \(d_t\) correspond to the model quantity

\[N - S(t)\]

where \(S(t)\) is the variable that models the number of the healthy population in the SIR model and N is the total size of the population.

The uncertainty in the parameters is propagated in the model and predictions for the future can be made.

To run the code, first install korali.

Then, download this repository

git clone
cd examples/study.cases/covid

Make sure you have installed the latest version (at least 1.4) of the Scipy library:

python3 -m pip install scipy==1.4.1

Also, get the pybind11 development source code by running:


Run the code main code,

./ --country greece           \
          --populationSize 10000000  \
          --nSamples 2000            \
          --nThreads 4               \
          --futureDays 2             \
          --validateData 1           \
          --percentages 0.5 0.99

Check the sampled distribution with

python3 -m korali.plot --dir data/_korali_samples/

In the diagonal of the figure, the marginal distribution of the parameters is shown in order, beta, gamma and sigma. The off-diagonal elements of the figure are plots of the pair the marginal distributions.

C++-optimized version

By default, the Python scripts will use scipy for integration. To use a C++ version, perform the following steps starting from the 5.coronavirus folder:

git submodule update --init --recursive
mkdir -p build
cd build
cmake ..
make -j4

The script will automatically detect if the C++ version is available.