episimlab.models package

Submodules

episimlab.models.epi_model module

class episimlab.models.epi_model.EpiModel(processes: Optional[dict] = None)

Bases: xsimlab.model.Model

Lightweight subclass of xsimlab.Model. Provides a framework for testing, running, and plotting an epidemiological model with default arguments

PROCESSES = {}
RUNNER_DEFAULTS = {'clocks': {'step': DatetimeIndex(['2020-03-01', '2020-03-02'], dtype='datetime64[ns]', freq='24H')}, 'input_vars': {}, 'output_vars': {}}
TAGS = ()
get_in_ds(config_fp: Optional[str] = None, input_vars: Optional[dict] = None, output_vars: Optional[dict] = None, **kwargs) xarray.core.dataset.Dataset
input_vars_from_config(config_fp: str) dict
parse_input_vars(d: dict) dict

Parse dictionary of input variables, returning a modified dictionary. Attempts to parse keys without the xsimlab-canonical double underscore denoting {process}__{variable}, dynamically assigning variables to processes that ingest them.

run(**kwargs) xarray.core.dataset.Dataset

episimlab.models.example_sir module

class episimlab.models.example_sir.ExampleSIR(processes: Optional[dict] = None)

Bases: episimlab.models.epi_model.EpiModel

PROCESSES = {'compt_model': <class 'episimlab.compt_model.ComptModel'>, 'rate_I2R': <class 'episimlab.models.example_sir.RecoveryRate'>, 'rate_S2I': <class 'episimlab.models.example_sir.FOI'>, 'setup_compt_graph': <class 'episimlab.models.example_sir.SetupComptGraph'>, 'setup_coords': <class 'episimlab.models.example_sir.SetupCoords'>, 'setup_phi': <class 'episimlab.models.example_sir.SetupPhi'>, 'setup_seed': <class 'episimlab.setup.seed.SeedGenerator'>, 'setup_state': <class 'episimlab.models.example_sir.SetupState'>, 'setup_sto': <class 'episimlab.setup.sto.SetupStochasticFromToggle'>}
RUNNER_DEFAULTS = {'clocks': {'step': DatetimeIndex(['2020-03-01', '2020-03-02', '2020-03-03', '2020-03-04',                '2020-03-05', '2020-03-06', '2020-03-07', '2020-03-08',                '2020-03-09', '2020-03-10', '2020-03-11', '2020-03-12',                '2020-03-13', '2020-03-14', '2020-03-15'],               dtype='datetime64[ns]', freq='24H')}, 'input_vars': {'beta': 0.08, 'gamma': 0.5, 'seed_entropy': 12345, 'sto_toggle': 0}, 'output_vars': {'compt_model__state': 'step'}}
TAGS = ('SIR', 'compartments::3')
plot(show=True)
class episimlab.models.example_sir.FOI(*, phi, state, beta, coords={})

Bases: episimlab.foi.BaseFOI

FOI that provides a rate_S2I

phiattr.Attribute

Pairwise contact patterns

Variable properties:

  • type : variable

  • intent : in

  • global name : phi

  • dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

betaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : beta

  • dimensions : ()

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

rate_S2Iattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • dimensions : ()

  • groups : edge_weight

PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
TAGS = ('FOI',)
run_step()
class episimlab.models.example_sir.RecoveryRate(*, gamma, state)

Bases: object

Provide a rate_I2R

rate_I2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_I2R

  • dimensions : ()

  • groups : edge_weight

gammaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

property I
run_step()
class episimlab.models.example_sir.SetupComptGraph

Bases: object

A single process in the model. Defines the directed graph compt_graph that defines the compartments and allowed transitions between them.

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : compt_graph

finalize()

This method is run once at the end of the simulation.

get_compt_graph() networkx.classes.digraph.DiGraph
initialize()

This method is run once at the beginning of the simulation.

visualize(path=None)

Visualize the compartment graph, saving as a file at path

class episimlab.models.example_sir.SetupCoords(*, compt_graph)

Bases: object

Initialize state coordinates. Imports compartment coordinates from the compartment graph.

comptattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : compt_coords

  • dimensions : (‘compt’,)

  • groups : coords

ageattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : age_coords

  • dimensions : (‘age’,)

  • groups : coords

riskattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : risk_coords

  • dimensions : (‘risk’,)

  • groups : coords

vertexattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : vertex_coords

  • dimensions : (‘vertex’,)

  • groups : coords

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : compt_graph

initialize()
class episimlab.models.example_sir.SetupPhi(*, coords={})

Bases: object

Set value of phi (contacts per unit time).

phiattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : phi

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

RANDOM_PHI_DATA = array([[0.89, 0.48, 0.31, 0.75, 0.07],        [0.64, 0.69, 0.13, 0.  , 0.05],        [0.46, 0.58, 0.19, 0.16, 0.11],        [0.53, 0.36, 0.26, 0.35, 0.13],        [0.68, 0.7 , 0.36, 0.23, 0.28]])
property coords
extend_phi_dims(data, coords) numpy.ndarray
initialize()
property phi_coords
property phi_dims
class episimlab.models.example_sir.SetupState(*, coords={})

Bases: object

Initialize state matrix

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : state

property coords
property dims
initialize()
class episimlab.models.example_sir.VaccRate(*, vacc_prop, state)

Bases: object

Provide a rate_S2V

rate_S2Vattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_S2V

  • dimensions : ()

  • groups : edge_weight

vacc_propattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : vacc_prop

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

property S
run_step()

episimlab.models.example_sirv module

class episimlab.models.example_sirv.ExampleSIRV(processes: Optional[dict] = None)

Bases: episimlab.models.epi_model.EpiModel

PROCESSES = {'compt_model': <class 'episimlab.compt_model.ComptModel'>, 'rate_I2R': <class 'episimlab.models.example_sirv.RecoveryRate'>, 'rate_S2I': <class 'episimlab.models.example_sirv.FOI'>, 'rate_S2V': <class 'episimlab.models.example_sirv.RateS2V'>, 'rate_V2I': <class 'episimlab.models.example_sirv.RateV2I'>, 'setup_compt_graph': <class 'episimlab.models.example_sirv.SetupComptGraph'>, 'setup_coords': <class 'episimlab.models.example_sirv.SetupCoords'>, 'setup_phi': <class 'episimlab.models.example_sirv.SetupPhi'>, 'setup_seed': <class 'episimlab.setup.seed.SeedGenerator'>, 'setup_state': <class 'episimlab.models.example_sirv.SetupState'>, 'setup_sto': <class 'episimlab.setup.sto.SetupStochasticFromToggle'>}
RUNNER_DEFAULTS = {'clocks': {'step': DatetimeIndex(['2020-03-01', '2020-03-02', '2020-03-03', '2020-03-04',                '2020-03-05', '2020-03-06', '2020-03-07', '2020-03-08',                '2020-03-09', '2020-03-10', '2020-03-11', '2020-03-12',                '2020-03-13', '2020-03-14', '2020-03-15'],               dtype='datetime64[ns]', freq='24H')}, 'input_vars': {'beta': 0.08, 'gamma': 0.5, 'seed_entropy': 12345, 'sto_toggle': 0, 'vacc_efficacy': 0.9, 'vacc_per_day': [0, 0, 5, 10, 10]}, 'output_vars': {'compt_model__state': 'step', 'rate_V2I__rate_V2I': 'step'}}
TAGS = ('SIRV', 'compartments::4')
plot()

Plot compartment populations over time.

plot_rate_V2I()

Plot incident escape infections (rate_V2I over time), stratified by age group.

plot_vacc()

Plot population of the vaccinated (V) compartment over time, stratified by age group.

class episimlab.models.example_sirv.FOI(*, phi, state, beta, coords={})

Bases: episimlab.foi.BaseFOI

FOI that provides a rate_S2I

phiattr.Attribute

Pairwise contact patterns

Variable properties:

  • type : variable

  • intent : in

  • global name : phi

  • dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

betaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : beta

  • dimensions : ()

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

rate_S2Iattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • dimensions : ()

  • groups : edge_weight

PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
TAGS = ('FOI',)
run_step()
class episimlab.models.example_sirv.RateS2V(*, vacc_per_day)

Bases: object

A single process in the model. Calculates a vaccination rate rate_S2V. Ingests a vacc_per_day with one dimension on age.

vacc_per_dayattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : vacc_per_day

  • dimensions : (‘age’,)

rate_S2Vattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_S2V

  • dimensions : ()

  • groups : edge_weight

run_step(step)

Calculate the rate_S2V at every step of the simulation. Set the rate to zero after step 5.

class episimlab.models.example_sirv.RateV2I(*, state, beta, coords={}, vacc_efficacy, phi)

Bases: episimlab.foi.BaseFOI

A single process in the model. Calculates a force of infection for vaccinated persons rate_V2I. This process inherits from the parent class BaseFOI.

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

betaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : beta

  • dimensions : ()

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

rate_V2Iattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_V2I

  • dimensions : (‘age’, ‘risk’, ‘vertex’)

  • groups : edge_weight

vacc_efficacyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : vacc_efficacy

  • dimensions : ()

phiattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : phi

S_COMPT_LABELS = 'V'
run_step()

Calculate the rate_V2I at every step of the simulation. Here, we make use of the foi method in the parent process BaseFOI.

class episimlab.models.example_sirv.RecoveryRate(*, gamma, state)

Bases: object

Provide a rate_I2R

rate_I2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_I2R

  • dimensions : ()

  • groups : edge_weight

gammaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

property I
run_step()
class episimlab.models.example_sirv.SetupComptGraph

Bases: object

A single process in the model. Defines the directed graph compt_graph that defines the compartments and allowed transitions between them.

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : compt_graph

finalize()

This method is run once at the end of the simulation.

get_compt_graph() networkx.classes.digraph.DiGraph

A method that returns a compartment graph as a directed graph. Uses the networkx package.

initialize()

This method is run once at the beginning of the simulation.

run_step()

This method is run once at every step of the simulation.

visualize()

Visualize the compartment graph, saving as a file at a path.

class episimlab.models.example_sirv.SetupCoords(*, compt_graph)

Bases: object

Initialize state coordinates. Imports compartment coordinates from the compartment graph.

comptattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : compt_coords

  • dimensions : (‘compt’,)

  • groups : coords

ageattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : age_coords

  • dimensions : (‘age’,)

  • groups : coords

riskattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : risk_coords

  • dimensions : (‘risk’,)

  • groups : coords

vertexattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : vertex_coords

  • dimensions : (‘vertex’,)

  • groups : coords

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : compt_graph

initialize()
class episimlab.models.example_sirv.SetupPhi(*, coords={})

Bases: object

Set value of phi (contacts per unit time).

phiattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : phi

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

RANDOM_PHI_DATA = array([[0.89, 0.48, 0.31, 0.75, 0.07],        [0.64, 0.69, 0.13, 0.  , 0.05],        [0.46, 0.58, 0.19, 0.16, 0.11],        [0.53, 0.36, 0.26, 0.35, 0.13],        [0.68, 0.7 , 0.36, 0.23, 0.28]])
property coords
extend_phi_dims(data, coords) numpy.ndarray
initialize()
property phi_coords
property phi_dims
class episimlab.models.example_sirv.SetupState(*, coords={})

Bases: object

Initialize state matrix

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : state

property coords
property dims
initialize()

episimlab.models.partition_v1 module

class episimlab.models.partition_v1.PartitionFromTravel(processes: Optional[dict] = None)

Bases: episimlab.models.epi_model.EpiModel

Nine-compartment SEIR model with partitioning from Episimlab V1

DATA_DIR = './tests/data'
PROCESSES = {'compt_model': <class 'episimlab.compt_model.ComptModel'>, 'int_per_day': <class 'episimlab.utils.datetime.IntPerDay'>, 'partition': <class 'episimlab.partition.partition.Partition'>, 'rate_E2P': <class 'episimlab.models.partition_v1.RateE2P'>, 'rate_E2Pa': <class 'episimlab.models.partition_v1.RateE2Pa'>, 'rate_E2Py': <class 'episimlab.models.partition_v1.RateE2Py'>, 'rate_Ia2R': <class 'episimlab.models.partition_v1.RateIa2R'>, 'rate_Ih2D': <class 'episimlab.models.partition_v1.RateIh2D'>, 'rate_Ih2R': <class 'episimlab.models.partition_v1.RateIh2R'>, 'rate_Iy2Ih': <class 'episimlab.models.partition_v1.RateIy2Ih'>, 'rate_Iy2R': <class 'episimlab.models.partition_v1.RateIy2R'>, 'rate_Pa2Ia': <class 'episimlab.models.partition_v1.RatePa2Ia'>, 'rate_Py2Iy': <class 'episimlab.models.partition_v1.RatePy2Iy'>, 'rate_S2E': <class 'episimlab.models.partition_v1.RateS2E'>, 'setup_compt_graph': <class 'episimlab.models.partition_v1.SetupComptGraph'>, 'setup_contacts': <class 'episimlab.partition.contacts.ContactsFromCSV'>, 'setup_coords': <class 'episimlab.models.partition_v1.SetupCoords'>, 'setup_gamma_Ia': <class 'episimlab.setup.greek.gamma.SetupGammaIa'>, 'setup_gamma_Ih': <class 'episimlab.setup.greek.gamma.SetupGammaIh'>, 'setup_gamma_Iy': <class 'episimlab.setup.greek.gamma.SetupGammaIy'>, 'setup_mu': <class 'episimlab.setup.greek.mu.SetupStaticMuIh2D'>, 'setup_nu': <class 'episimlab.models.partition_v1.SetupNuDefault'>, 'setup_pi': <class 'episimlab.models.partition_v1.SetupPiDefault'>, 'setup_rho_Ia': <class 'episimlab.setup.greek.rho.SetupRhoIa'>, 'setup_rho_Iy': <class 'episimlab.setup.greek.rho.SetupRhoIy'>, 'setup_seed': <class 'episimlab.setup.seed.SeedGenerator'>, 'setup_sigma': <class 'episimlab.setup.greek.sigma.SetupStaticSigmaFromExposedPara'>, 'setup_state': <class 'episimlab.models.partition_v1.SetupState'>, 'setup_sto': <class 'episimlab.setup.sto.SetupStochasticFromToggle'>, 'setup_travel': <class 'episimlab.partition.travel_pat.TravelPatRepeatDaily'>}
RUNNER_DEFAULTS = {'clocks': {'step': DatetimeIndex(['2020-03-11', '2020-03-12'], dtype='datetime64[ns]', freq='24H')}, 'input_vars': {'contacts_fp': './tests/data/polymod_contacts.csv', 'rate_E2Pa__tau': 0.57, 'rate_E2Py__tau': 0.57, 'rate_Iy2Ih__eta': 0.169492, 'rate_S2E__beta': 0.35, 'setup_gamma_Ia__tri_Iy2R_para': [3.0, 4.0, 5.0], 'setup_gamma_Ih__tri_Ih2R': [9.4, 10.7, 12.8], 'setup_mu__tri_Ih2D': [5.2, 8.1, 10.1], 'setup_rho_Ia__tri_Pa2Ia': 2.3, 'setup_rho_Iy__tri_Py2Iy': 2.3, 'setup_seed__seed_entropy': 12345, 'setup_sigma__tri_exposed_para': [1.9, 2.9, 3.9], 'setup_sto__sto_toggle': 0, 'travel_pat_fp': './tests/data/travel_pat0.csv'}, 'output_vars': {'compt_model__state': 'step'}}
TAGS = ('SEIR', 'compartments::9', 'contact-partitioning')
plot(show=True)
class episimlab.models.partition_v1.RateE2P(*, sigma, state, int_per_day)

Bases: object

Provide a rate_E2P

rate_E2Pattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_E2P

  • dimensions : ()

sigmaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : sigma

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.partition_v1.RateE2Pa(*, tau, rate_E2P)

Bases: object

Provide a rate_E2Pa

rate_E2Paattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_E2Pa

  • dimensions : ()

  • groups : edge_weight

tauattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : tau

  • dimensions : ()

rate_E2Pattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : rate_E2P

run_step()
class episimlab.models.partition_v1.RateE2Py(*, tau, rate_E2P)

Bases: object

Provide a rate_E2Py

rate_E2Pyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_E2Py

  • dimensions : ()

  • groups : edge_weight

tauattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : tau

  • dimensions : ()

rate_E2Pattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : rate_E2P

run_step()
class episimlab.models.partition_v1.RateIa2R(*, gamma_Ia, state)

Bases: object

Provide a rate_Ia2R

rate_Ia2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ia2R

  • dimensions : ()

  • groups : edge_weight

gamma_Iaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma_Ia

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.partition_v1.RateIh2D(*, mu, nu, state, int_per_day)

Bases: object

Provide a rate_Ih2D

rate_Ih2Dattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ih2D

  • dimensions : ()

  • groups : edge_weight

muattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : mu

  • dimensions : ()

nuattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : nu

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.partition_v1.RateIh2R(*, gamma_Ih, nu, state, int_per_day)

Bases: object

Provide a rate_Ih2R

rate_Ih2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ih2R

  • dimensions : ()

  • groups : edge_weight

gamma_Ihattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma_Ih

  • dimensions : ()

nuattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : nu

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.partition_v1.RateIy2Ih(*, eta, pi, state, int_per_day)

Bases: object

Provide a rate_Iy2Ih

rate_Iy2Ihattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Iy2Ih

  • dimensions : ()

  • groups : edge_weight

etaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : eta

  • dimensions : ()

piattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : pi

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.partition_v1.RateIy2R(*, gamma_Iy, pi, state)

Bases: object

Provide a rate_Iy2R

rate_Iy2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Iy2R

  • dimensions : ()

  • groups : edge_weight

gamma_Iyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma_Iy

  • dimensions : ()

piattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : pi

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.partition_v1.RatePa2Ia(*, rho_Ia, state)

Bases: object

Provide a rate_Pa2Ia

rate_Pa2Iaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Pa2Ia

  • dimensions : ()

  • groups : edge_weight

rho_Iaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : rho_Ia

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.partition_v1.RatePy2Iy(*, rho_Iy, state)

Bases: object

Provide a rate_Py2Iy

rate_Py2Iyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Py2Iy

  • dimensions : ()

  • groups : edge_weight

rho_Iyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : rho_Iy

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.partition_v1.RateS2E(*, phi, state, beta, coords={})

Bases: episimlab.foi.BaseFOI

FOI that provides a rate_S2E

phiattr.Attribute

Pairwise contact patterns

Variable properties:

  • type : variable

  • intent : in

  • global name : phi

  • dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

betaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : beta

  • dimensions : ()

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

rate_S2Eattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • dimensions : ()

  • groups : edge_weight

property I
PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
property S
run_step()
class episimlab.models.partition_v1.SetupComptGraph

Bases: object

Generate a 9-node compartment graph

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : compt_graph

get_compt_graph() networkx.classes.digraph.DiGraph
initialize()
vis()
class episimlab.models.partition_v1.SetupCoords(*, travel_pat, compt_graph)

Bases: object

Initialize state coordinates. Imports the travel patterns as xarray.DataArray travel_pat to retrieve coordinates for age and vertex. Imports coordinates for compt from the compartment graph compt_graph.

travel_patattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : travel_pat

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : compt_graph

comptattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : compt_coords

  • dimensions : (‘compt’,)

  • groups : coords

ageattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : age_coords

  • dimensions : (‘age’,)

  • groups : coords

riskattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : risk_coords

  • dimensions : (‘risk’,)

  • groups : coords

vertexattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : vertex_coords

  • dimensions : (‘vertex’,)

  • groups : coords

initialize()
class episimlab.models.partition_v1.SetupNuDefault(*, coords={})

Bases: object

Provide a default value for nu

nuattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : nu

  • dimensions : (‘age’,)

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

DIMS = ['age']
property coords
property dims
initialize()
class episimlab.models.partition_v1.SetupPiDefault(*, coords={})

Bases: object

Provide a default value for pi

piattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : pi

  • dimensions : (‘risk’, ‘age’)

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

DIMS = ('risk', 'age')
property coords
property dims
initialize()
class episimlab.models.partition_v1.SetupState(*, coords={})

Bases: object

Initialize state matrix

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : state

property coords
property dims
initialize()

episimlab.models.vaccine module

class episimlab.models.vaccine.BetaReduction(*, beta, beta_reduction)

Bases: object

betaattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : beta

reduced_betaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : reduced_beta

  • dimensions : ()

beta_reductionattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : beta_reduction

  • dimensions : ()

run_step()
class episimlab.models.vaccine.RateE2P(*, sigma, state, int_per_day)

Bases: object

Provide a rate_E2P

rate_E2Pattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_E2P

  • dimensions : ()

sigmaattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : sigma

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.vaccine.RateE2Pa(*, tau, rate_E2P)

Bases: object

Provide a rate_E2Pa

rate_E2Paattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_E2Pa

  • dimensions : ()

  • groups : edge_weight

tauattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : tau

  • dimensions : ()

rate_E2Pattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : rate_E2P

run_step()
class episimlab.models.vaccine.RateE2Py(*, tau, rate_E2P)

Bases: object

Provide a rate_E2Py

rate_E2Pyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_E2Py

  • dimensions : ()

  • groups : edge_weight

tauattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : tau

  • dimensions : ()

rate_E2Pattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : rate_E2P

run_step()
class episimlab.models.vaccine.RateEv2P(*, sigma, state, int_per_day)

Bases: object

Provide a rate_Ev2P

rate_Ev2Pattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ev2P

  • dimensions : ()

sigmaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : sigma

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.vaccine.RateEv2Pa(*, tau_v, rate_Ev2P)

Bases: object

Provide a `rate_Ev2Pa

rate_Ev2Paattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ev2Pa

  • dimensions : ()

  • groups : edge_weight

tau_vattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : tau_v

  • dimensions : ()

rate_Ev2Pattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : rate_Ev2P

run_step()
class episimlab.models.vaccine.RateEv2Py(*, tau_v, rate_Ev2P)

Bases: object

Provide a `rate_Ev2Py

rate_Ev2Pyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ev2Py

  • dimensions : ()

  • groups : edge_weight

tau_vattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : tau_v

  • dimensions : ()

rate_Ev2Pattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : rate_Ev2P

run_step()
class episimlab.models.vaccine.RateIa2R(*, gamma_Ia, state)

Bases: object

Provide a rate_Ia2R

rate_Ia2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ia2R

  • dimensions : ()

  • groups : edge_weight

gamma_Iaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma_Ia

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.vaccine.RateIh2D(*, mu, nu, state, int_per_day)

Bases: object

Provide a rate_Ih2D

rate_Ih2Dattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ih2D

  • dimensions : ()

  • groups : edge_weight

muattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : mu

  • dimensions : ()

nuattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : nu

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.vaccine.RateIh2R(*, gamma_Ih, nu, state, int_per_day)

Bases: object

Provide a rate_Ih2R

rate_Ih2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Ih2R

  • dimensions : ()

  • groups : edge_weight

gamma_Ihattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma_Ih

  • dimensions : ()

nuattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : nu

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.vaccine.RateIy2Ih(*, eta, pi, state, int_per_day)

Bases: object

Provide a rate_Iy2Ih

rate_Iy2Ihattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Iy2Ih

  • dimensions : ()

  • groups : edge_weight

etaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : eta

  • dimensions : ()

piattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : pi

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

int_per_dayattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : int_per_day

run_step()
class episimlab.models.vaccine.RateIy2R(*, gamma_Iy, pi, state)

Bases: object

Provide a rate_Iy2R

rate_Iy2Rattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Iy2R

  • dimensions : ()

  • groups : edge_weight

gamma_Iyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : gamma_Iy

  • dimensions : ()

piattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : pi

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.vaccine.RatePa2Ia(*, rho_Ia, state)

Bases: object

Provide a rate_Pa2Ia

rate_Pa2Iaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Pa2Ia

  • dimensions : ()

  • groups : edge_weight

rho_Iaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : rho_Ia

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.vaccine.RatePy2Iy(*, rho_Iy, state)

Bases: object

Provide a rate_Py2Iy

rate_Py2Iyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_Py2Iy

  • dimensions : ()

  • groups : edge_weight

rho_Iyattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : rho_Iy

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

run_step()
class episimlab.models.vaccine.RateS2E(*, phi, state, beta, coords={})

Bases: episimlab.foi.BaseFOI

FOI that provides a rate_S2E

phiattr.Attribute

Pairwise contact patterns

Variable properties:

  • type : variable

  • intent : in

  • global name : phi

  • dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

betaattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : beta

  • dimensions : ()

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

rate_S2Eattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • dimensions : ()

  • groups : edge_weight

property I
PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
property S
TAGS = ('model::ElevenComptV1', 'FOI')
run_step()
class episimlab.models.vaccine.RateS2V(*, doses_delivered, eff_vaccine)

Bases: object

Vaccination dosage model

rate_S2Vattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : rate_S2V

  • dimensions : ()

  • groups : edge_weight

doses_deliveredattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : doses_delivered

eff_vaccineattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : in

  • global name : eff_vaccine

  • dimensions : ()

run_step()
class episimlab.models.vaccine.RateV2Ev(*, state, coords={}, phi, beta)

Bases: episimlab.foi.BaseFOI

FOI that provides a rate_V2Ev

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

phiattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : phi

betaattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : reduced_beta

rate_V2Evattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • dimensions : ()

  • groups : edge_weight

I_COMPT_LABELS = ('Ia', 'Iy', 'Pa', 'Py')
S_COMPT_LABELS = 'V'
TAGS = ('model::ElevenComptV1', 'FOI')
run_step()
class episimlab.models.vaccine.SetupComptGraph

Bases: object

Generate an 11-node compartment graph

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : compt_graph

get_compt_graph() networkx.classes.digraph.DiGraph
initialize()
vis(path=None)
class episimlab.models.vaccine.SetupCoords(*, travel_pat, compt_graph)

Bases: object

Initialize state coordinates. Imports the travel patterns as xarray.DataArray travel_pat to retrieve coordinates for age and vertex. Imports coordinates for compt from the compartment graph compt_graph.

travel_patattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : travel_pat

compt_graphattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : compt_graph

comptattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : compt_coords

  • dimensions : (‘compt’,)

  • groups : coords

ageattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : age_coords

  • dimensions : (‘age’,)

  • groups : coords

riskattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : risk_coords

  • dimensions : (‘risk’,)

  • groups : coords

vertexattr.Attribute

No description given

Variable properties:

  • type : index

  • intent : out

  • global name : vertex_coords

  • dimensions : (‘vertex’,)

  • groups : coords

initialize()
class episimlab.models.vaccine.SetupNuDefault(*, coords={})

Bases: object

Provide a default value for nu

nuattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : nu

  • dimensions : (‘age’,)

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

DIMS = ['age']
property coords
property dims
initialize()
class episimlab.models.vaccine.SetupPiDefault(*, coords={})

Bases: object

Provide a default value for pi

piattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : pi

  • dimensions : (‘risk’, ‘age’)

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

DIMS = ('risk', 'age')
property coords
property dims
initialize()
class episimlab.models.vaccine.SetupState(*, coords={})

Bases: object

Initialize state matrix

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : out

  • global name : state

property coords
property dims
initialize()
class episimlab.models.vaccine.SetupVaccineDoses(*, state, coords={})

Bases: object

Initialize vaccine doses

max_daily_dosesattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : max_daily_doses

  • dimensions : (‘age’, ‘risk’)

doses_deliveredattr.Attribute

No description given

Variable properties:

  • type : variable

  • intent : out

  • global name : doses_delivered

  • dimensions : ()

stateattr.Attribute

No description given

Variable properties:

  • type : global

  • intent : in

  • global name : state

_coordsattr.Attribute

Mapping of all variables that belong to group ‘coords’

Variable properties:

  • type : group_dict

  • intent : in

  • default value : {}

DIMS = ('age', 'risk')
property S
property coords
property dims
property eligible_pop
initialize()
run_step()
class episimlab.models.vaccine.Vaccine(processes: Optional[dict] = None)

Bases: episimlab.models.epi_model.EpiModel

Nine-compartment SEIR model with partitioning from Episimlab V1

DATA_DIR = './tests/data'
PROCESSES = {'beta_reduction': <class 'episimlab.models.vaccine.BetaReduction'>, 'compt_model': <class 'episimlab.compt_model.ComptModel'>, 'int_per_day': <class 'episimlab.utils.datetime.IntPerDay'>, 'partition': <class 'episimlab.partition.partition.Partition'>, 'rate_E2P': <class 'episimlab.models.vaccine.RateE2P'>, 'rate_E2Pa': <class 'episimlab.models.vaccine.RateE2Pa'>, 'rate_E2Py': <class 'episimlab.models.vaccine.RateE2Py'>, 'rate_Ev2P': <class 'episimlab.models.vaccine.RateEv2P'>, 'rate_Ev2Pa': <class 'episimlab.models.vaccine.RateEv2Pa'>, 'rate_Ev2Py': <class 'episimlab.models.vaccine.RateEv2Py'>, 'rate_Ia2R': <class 'episimlab.models.vaccine.RateIa2R'>, 'rate_Ih2D': <class 'episimlab.models.vaccine.RateIh2D'>, 'rate_Ih2R': <class 'episimlab.models.vaccine.RateIh2R'>, 'rate_Iy2Ih': <class 'episimlab.models.vaccine.RateIy2Ih'>, 'rate_Iy2R': <class 'episimlab.models.vaccine.RateIy2R'>, 'rate_Pa2Ia': <class 'episimlab.models.vaccine.RatePa2Ia'>, 'rate_Py2Iy': <class 'episimlab.models.vaccine.RatePy2Iy'>, 'rate_S2E': <class 'episimlab.models.vaccine.RateS2E'>, 'rate_S2V': <class 'episimlab.models.vaccine.RateS2V'>, 'rate_V2Ev': <class 'episimlab.models.vaccine.RateV2Ev'>, 'setup_compt_graph': <class 'episimlab.models.vaccine.SetupComptGraph'>, 'setup_contacts': <class 'episimlab.partition.contacts.ContactsFromCSV'>, 'setup_coords': <class 'episimlab.models.vaccine.SetupCoords'>, 'setup_doses': <class 'episimlab.models.vaccine.SetupVaccineDoses'>, 'setup_gamma_Ia': <class 'episimlab.setup.greek.gamma.SetupGammaIa'>, 'setup_gamma_Ih': <class 'episimlab.setup.greek.gamma.SetupGammaIh'>, 'setup_gamma_Iy': <class 'episimlab.setup.greek.gamma.SetupGammaIy'>, 'setup_mu': <class 'episimlab.setup.greek.mu.SetupStaticMuIh2D'>, 'setup_nu': <class 'episimlab.models.vaccine.SetupNuDefault'>, 'setup_pi': <class 'episimlab.models.vaccine.SetupPiDefault'>, 'setup_rho_Ia': <class 'episimlab.setup.greek.rho.SetupRhoIa'>, 'setup_rho_Iy': <class 'episimlab.setup.greek.rho.SetupRhoIy'>, 'setup_seed': <class 'episimlab.setup.seed.SeedGenerator'>, 'setup_sigma': <class 'episimlab.setup.greek.sigma.SetupStaticSigmaFromExposedPara'>, 'setup_state': <class 'episimlab.models.vaccine.SetupState'>, 'setup_sto': <class 'episimlab.setup.sto.SetupStochasticFromToggle'>, 'setup_travel': <class 'episimlab.partition.travel_pat.TravelPatFromCSV'>}
RUNNER_DEFAULTS = {'clocks': {'step': DatetimeIndex(['2020-03-11', '2020-03-12'], dtype='datetime64[ns]', freq='24H')}, 'input_vars': {'beta_reduction': 0.1, 'contacts_fp': './tests/data/polymod_contacts.csv', 'rate_E2Pa__tau': 0.57, 'rate_E2Py__tau': 0.57, 'rate_Ev2Pa__tau_v': 0.055, 'rate_Ev2Py__tau_v': 0.055, 'rate_Iy2Ih__eta': 0.169492, 'rate_S2E__beta': 0.35, 'rate_S2V__eff_vaccine': 0.8, 'setup_gamma_Ia__tri_Iy2R_para': [3.0, 4.0, 5.0], 'setup_gamma_Ih__tri_Ih2R': [9.4, 10.7, 12.8], 'setup_mu__tri_Ih2D': [5.2, 8.1, 10.1], 'setup_rho_Ia__tri_Pa2Ia': 2.3, 'setup_rho_Iy__tri_Py2Iy': 2.3, 'setup_seed__seed_entropy': 12345, 'setup_sigma__tri_exposed_para': [1.9, 2.9, 3.9], 'setup_sto__sto_toggle': 0, 'travel_pat_fp': './tests/data/travel_pat0.csv'}, 'output_vars': {'compt_model__state': 'step'}}
TAGS = ('SEIR', 'compartments::11', 'contact-partitioning')
plot(show=True)
episimlab.models.vaccine.binomial(n, p, size=None)

Draw samples from a binomial distribution.

Samples are drawn from a binomial distribution with specified parameters, n trials and p probability of success where n an integer >= 0 and p is in the interval [0,1]. (n may be input as a float, but it is truncated to an integer in use)

Note

New code should use the binomial method of a default_rng() instance instead; please see the random-quick-start.

nint or array_like of ints

Parameter of the distribution, >= 0. Floats are also accepted, but they will be truncated to integers.

pfloat or array_like of floats

Parameter of the distribution, >= 0 and <=1.

sizeint or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if n and p are both scalars. Otherwise, np.broadcast(n, p).size samples are drawn.

outndarray or scalar

Drawn samples from the parameterized binomial distribution, where each sample is equal to the number of successes over the n trials.

scipy.stats.binomprobability density function, distribution or

cumulative density function, etc.

Generator.binomial: which should be used for new code.

The probability density for the binomial distribution is

\[P(N) = \binom{n}{N}p^N(1-p)^{n-N},\]

where \(n\) is the number of trials, \(p\) is the probability of success, and \(N\) is the number of successes.

When estimating the standard error of a proportion in a population by using a random sample, the normal distribution works well unless the product p*n <=5, where p = population proportion estimate, and n = number of samples, in which case the binomial distribution is used instead. For example, a sample of 15 people shows 4 who are left handed, and 11 who are right handed. Then p = 4/15 = 27%. 0.27*15 = 4, so the binomial distribution should be used in this case.

1

Dalgaard, Peter, “Introductory Statistics with R”, Springer-Verlag, 2002.

2

Glantz, Stanton A. “Primer of Biostatistics.”, McGraw-Hill, Fifth Edition, 2002.

3

Lentner, Marvin, “Elementary Applied Statistics”, Bogden and Quigley, 1972.

4

Weisstein, Eric W. “Binomial Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/BinomialDistribution.html

5

Wikipedia, “Binomial distribution”, https://en.wikipedia.org/wiki/Binomial_distribution

Draw samples from the distribution:

>>> n, p = 10, .5  # number of trials, probability of each trial
>>> s = np.random.binomial(n, p, 1000)
# result of flipping a coin 10 times, tested 1000 times.

A real world example. A company drills 9 wild-cat oil exploration wells, each with an estimated probability of success of 0.1. All nine wells fail. What is the probability of that happening?

Let’s do 20,000 trials of the model, and count the number that generate zero positive results.

>>> sum(np.random.binomial(9, 0.1, 20000) == 0)/20000.
# answer = 0.38885, or 38%.
episimlab.models.vaccine.hypergeometric(ngood, nbad, nsample, size=None)

Draw samples from a Hypergeometric distribution.

Samples are drawn from a hypergeometric distribution with specified parameters, ngood (ways to make a good selection), nbad (ways to make a bad selection), and nsample (number of items sampled, which is less than or equal to the sum ngood + nbad).

Note

New code should use the hypergeometric method of a default_rng() instance instead; please see the random-quick-start.

ngoodint or array_like of ints

Number of ways to make a good selection. Must be nonnegative.

nbadint or array_like of ints

Number of ways to make a bad selection. Must be nonnegative.

nsampleint or array_like of ints

Number of items sampled. Must be at least 1 and at most ngood + nbad.

sizeint or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if ngood, nbad, and nsample are all scalars. Otherwise, np.broadcast(ngood, nbad, nsample).size samples are drawn.

outndarray or scalar

Drawn samples from the parameterized hypergeometric distribution. Each sample is the number of good items within a randomly selected subset of size nsample taken from a set of ngood good items and nbad bad items.

scipy.stats.hypergeomprobability density function, distribution or

cumulative density function, etc.

Generator.hypergeometric: which should be used for new code.

The probability density for the Hypergeometric distribution is

\[P(x) = \frac{\binom{g}{x}\binom{b}{n-x}}{\binom{g+b}{n}},\]

where \(0 \le x \le n\) and \(n-b \le x \le g\)

for P(x) the probability of x good results in the drawn sample, g = ngood, b = nbad, and n = nsample.

Consider an urn with black and white marbles in it, ngood of them are black and nbad are white. If you draw nsample balls without replacement, then the hypergeometric distribution describes the distribution of black balls in the drawn sample.

Note that this distribution is very similar to the binomial distribution, except that in this case, samples are drawn without replacement, whereas in the Binomial case samples are drawn with replacement (or the sample space is infinite). As the sample space becomes large, this distribution approaches the binomial.

1

Lentner, Marvin, “Elementary Applied Statistics”, Bogden and Quigley, 1972.

2

Weisstein, Eric W. “Hypergeometric Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/HypergeometricDistribution.html

3

Wikipedia, “Hypergeometric distribution”, https://en.wikipedia.org/wiki/Hypergeometric_distribution

Draw samples from the distribution:

>>> ngood, nbad, nsamp = 100, 2, 10
# number of good, number of bad, and number of samples
>>> s = np.random.hypergeometric(ngood, nbad, nsamp, 1000)
>>> from matplotlib.pyplot import hist
>>> hist(s)
#   note that it is very unlikely to grab both bad items

Suppose you have an urn with 15 white and 15 black marbles. If you pull 15 marbles at random, how likely is it that 12 or more of them are one color?

>>> s = np.random.hypergeometric(15, 15, 15, 100000)
>>> sum(s>=12)/100000. + sum(s<=3)/100000.
#   answer = 0.003 ... pretty unlikely!

Module contents