epistoch package

Top-level package for EpiStoch.

Submodules

epistoch.experiments module

epistoch.experiments.compare_models(name, dist, N, I0=1, num_days=100, R0=2.25, do_plots=True, use_latex=False, plot_path='.', plot_ext='pdf')[source]
epistoch.experiments.variance_analysis(N=1000000, I0=1, num_days=100, R0=2.25, infectious_period_mean=4.4, cvs=[0.5, 1.0, 2.0], use_latex=False, plot_path='.', plot_ext='pdf')[source]

epistoch.seird_ph module

Created on Sun Apr 26 21:50:11 2020

@author: Germán Riaño, PhD

epistoch.seird_ph.seird_ph(name, population, beta, exposed_time, time_to_die, time_to_recover, fatality_rate, num_days, I0=1, logger=None)[source]

Compute a SEIRD model with Phase-Type distribution for the different stages.

Parameters:
  • name (string) – Model name.
  • population (int or float) – Population size.
  • beta (float) – Contagion rate.
  • exposed_time (PH distribution) – Distribution of time exposed, not yet infectious.
  • time_to_die (PH distribution) – Time to die after becoming infectious.
  • time_to_recover (PH distribution) – Time to recover after becoming infectious.
  • fatality_rate (float) – Percentage of individuals that die.
  • num_days (int) – Number of days ot analyze.
  • I0 (int, optional) – Initial infected population. The default is 1.
  • logger (Logger object, optional) – Logger object. If not given default logging is used.
Returns:

result

Dictionary with fields:
  • name: model name
  • population: Total population
  • data: data Frame with columns
    • S : Susceptible,
    • E : Exposed,
    • I : Infectious (Dying or recovering),
    • Rc : Total Recovered,
    • D : Total deaths
    • R : Removed (R+D),

Return type:

dict

epistoch.sir_g module

Created on Sat Apr 11 12:20:32 2020

@author: Germán Riaño (griano@germanriano.com)

epistoch.sir_g.sir_classical(name, population, reproductive_factor, infectious_period_mean, num_days, I0=1.0, S0=None, times=None)[source]

Solves a classical SIR model.

Parameters:
  • name (string) – Model name
  • population (float) – total population size
  • reproductive_factor (float) – basic reproductive factor(R0)
  • infectious_period_mean (float) – expected value of Infectious Period Time
  • I0 (float) – Initial infectious population
  • S0 (float) – Initial susceptible population (optinal, defaults to all but I0)
  • num_days (int) – number of days to run
  • times (array of float) – times where the functions should be reported. Defaults to np.linspace(0, num_days, num_days + 1)
Returns:

Dictionary with fields:
  • name: model name
  • population: Total population
  • total_infected
  • data: data Frame with columns
    • S : Susceptible,
    • I : Infectious (Dying or recovering),
    • R : Removed (recovered + deaths),

Return type:

dict

epistoch.sir_g.sir_g(name, population, reproductive_factor, infectious_time_distribution, num_days, I0=1.0, S0=None, num_periods=None, method='loss', logger=None)[source]

Solves a SIR-G model.

Parameters:
  • name (string) – Model name
  • population (float) – total population size
  • reproductive_factor (float) – basic reproductive factor(R0)
  • infectious_time_distribution (scipy.stats.rv_continuous) – expected value of Infectious Period Time
  • num_days (int) – number of days to run
  • I0 (float) – Initial infectious population
  • S0 (float) – Initial susceptible population (optional, defaults to all but I0)
  • num_periods (int) – Number of periods to use for computations. Higher number will lead ot more precise computation.
  • method (string) – Method used for the internal integral
  • logger – Logger object
Returns:

Dictionary with fields:
  • name: model name
  • population: Total population
  • total_infected
  • data: data Frame with columns
    • S : Susceptible,
    • I : Infectious (Dying or recovering),
    • R : Removed (recovered + deaths),

Return type:

dict

epistoch.sir_phg module

Created on Sun Apr 26 11:43:11 2020

@author: Germán Riaño, PhD

epistoch.sir_phg.sir_phg(name, population, beta, infectious_time_distribution, num_days=160, I0=1.0, S0=None, logger=None, report_phases=False)[source]

Compute a SIR-PH model

Parameters:
  • name (string) – Model name
  • population (float) – Total population.
  • beta (float, optional) – Contagion rate. The default is 0.2.
  • infectious_time_distribution (phase) – Must be a PH distribution.
  • num_days (int) – Number of days to run.
  • I0 (float, optional) – initial population. The default is 1.0.
  • S0 (float or int, optional) – Initial susceptible. The default is all but I0.
  • logger (Logger, optional) – Logger object. If none is given, default logging used.
  • report_phases (boolean, optional) – Whether to include phase levels and removed from every level in the report. The default is False.
Returns:

  • dict
  • A dictionary with these fields
    • name: model name
    • population: total population
    • total_infected: estimation of total infected individuals
    • data: DataFrame with columns
      • S : Susceptible
      • I : Infected individuals
      • R : Removed Individuals
      • Optionally: I-Phase0,…,I-Phase(n-1), and R-Phase0,…R-Phase(n-1)

epistoch.sir_phg.to_array(*args)[source]