This section shows how to use the distributions from Episuite. Distributions are one important component for simulation and modelling, in this example we will show how to create a bootstrap distribution from an empirical distribution of durations using the EmpiricalBootstrap distribution.


In the example below, we will use a sample dataset that comes embedded in Episuite with real data from the SARS-CoV-2 outbreak in south of Brazil. This dataset can be accessed using the admissions_sample() function from the data module.

See also

Module episuite.distributions

Documentation of the episuite.distributions module.

Module episuite.data

Documentation of the episuite.data module.

from matplotlib import pyplot as plt
import seaborn as sns

from episuite import durations
from episuite import distributions
from episuite import data

Loading sample data

sample_data = data.admissions_sample()
0 2020-06-17 2020-08-03 RECOVERY
1 2020-06-11 2020-06-21 DEATH
2 2020-07-12 2020-08-02 DEATH
3 2020-06-25 2020-07-31 DEATH
4 2020-07-24 2020-08-16 DEATH
dur = durations.Durations(sample_data)

Build a bootstrap distribution

You can build a EmpiricalBootstrap distribution by constructing it using the durations distribution, like in the example below:

duration_distribution = dur.get_stay_distribution()
duration_bootstrap = distributions.EmpiricalBootstrap(duration_distribution)

Or you can use the method get_bootstrap() from the Durations class that will have the same effect:

duration_bootstrap = dur.get_bootstrap()

Sampling from the distribution

fig = plt.figure(figsize=(10, 6))
for i in range(100):
                alpha=0.01, lw=0.2, cut=0,
plt.xlim(0, 100)