episimlab.models package
Submodules
episimlab.models.epi_model module
- class episimlab.models.epi_model.EpiModel(processes: Optional[dict] = None)
Bases:
xsimlab.model.ModelLightweight 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.BaseFOIFOI that provides a rate_S2I
- phi
attr.Attribute Pairwise contact patterns
Variable properties:
type :
variableintent :
inglobal name : phi
dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- beta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : beta
dimensions : ()
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- rate_S2I
attr.Attribute No description given
Variable properties:
type :
variableintent :
outdimensions : ()
groups : edge_weight
- PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
- TAGS = ('FOI',)
- run_step()
- phi
- class episimlab.models.example_sir.RecoveryRate(*, gamma, state)
Bases:
objectProvide a rate_I2R
- rate_I2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_I2R
dimensions : ()
groups : edge_weight
- gamma
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- property I
- run_step()
- rate_I2R
- class episimlab.models.example_sir.SetupComptGraph
Bases:
objectA single process in the model. Defines the directed graph compt_graph that defines the compartments and allowed transitions between them.
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal 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
- compt_graph
- class episimlab.models.example_sir.SetupCoords(*, compt_graph)
Bases:
objectInitialize state coordinates. Imports compartment coordinates from the compartment graph.
- compt
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : compt_coords
dimensions : (‘compt’,)
groups : coords
- age
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : age_coords
dimensions : (‘age’,)
groups : coords
- risk
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : risk_coords
dimensions : (‘risk’,)
groups : coords
- vertex
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : vertex_coords
dimensions : (‘vertex’,)
groups : coords
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : compt_graph
- initialize()
- compt
- class episimlab.models.example_sir.SetupPhi(*, coords={})
Bases:
objectSet value of phi (contacts per unit time).
- phi
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : phi
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault 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
- phi
- class episimlab.models.example_sir.SetupState(*, coords={})
Bases:
objectInitialize state matrix
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : state
- property coords
- property dims
- initialize()
- _coords
- class episimlab.models.example_sir.VaccRate(*, vacc_prop, state)
Bases:
objectProvide a rate_S2V
- rate_S2V
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_S2V
dimensions : ()
groups : edge_weight
- vacc_prop
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : vacc_prop
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- property S
- run_step()
- rate_S2V
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.BaseFOIFOI that provides a rate_S2I
- phi
attr.Attribute Pairwise contact patterns
Variable properties:
type :
variableintent :
inglobal name : phi
dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- beta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : beta
dimensions : ()
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- rate_S2I
attr.Attribute No description given
Variable properties:
type :
variableintent :
outdimensions : ()
groups : edge_weight
- PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
- TAGS = ('FOI',)
- run_step()
- phi
- class episimlab.models.example_sirv.RateS2V(*, vacc_per_day)
Bases:
objectA single process in the model. Calculates a vaccination rate rate_S2V. Ingests a vacc_per_day with one dimension on age.
- vacc_per_day
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : vacc_per_day
dimensions : (‘age’,)
- rate_S2V
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal 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.
- vacc_per_day
- class episimlab.models.example_sirv.RateV2I(*, state, beta, coords={}, vacc_efficacy, phi)
Bases:
episimlab.foi.BaseFOIA single process in the model. Calculates a force of infection for vaccinated persons rate_V2I. This process inherits from the parent class BaseFOI.
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- beta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : beta
dimensions : ()
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- rate_V2I
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_V2I
dimensions : (‘age’, ‘risk’, ‘vertex’)
groups : edge_weight
- vacc_efficacy
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : vacc_efficacy
dimensions : ()
- phi
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal 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.
- state
- class episimlab.models.example_sirv.RecoveryRate(*, gamma, state)
Bases:
objectProvide a rate_I2R
- rate_I2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_I2R
dimensions : ()
groups : edge_weight
- gamma
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- property I
- run_step()
- rate_I2R
- class episimlab.models.example_sirv.SetupComptGraph
Bases:
objectA single process in the model. Defines the directed graph compt_graph that defines the compartments and allowed transitions between them.
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal 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.
- compt_graph
- class episimlab.models.example_sirv.SetupCoords(*, compt_graph)
Bases:
objectInitialize state coordinates. Imports compartment coordinates from the compartment graph.
- compt
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : compt_coords
dimensions : (‘compt’,)
groups : coords
- age
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : age_coords
dimensions : (‘age’,)
groups : coords
- risk
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : risk_coords
dimensions : (‘risk’,)
groups : coords
- vertex
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : vertex_coords
dimensions : (‘vertex’,)
groups : coords
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : compt_graph
- initialize()
- compt
- class episimlab.models.example_sirv.SetupPhi(*, coords={})
Bases:
objectSet value of phi (contacts per unit time).
- phi
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : phi
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault 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
- phi
- class episimlab.models.example_sirv.SetupState(*, coords={})
Bases:
objectInitialize state matrix
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : state
- property coords
- property dims
- initialize()
- _coords
episimlab.models.partition_v1 module
- class episimlab.models.partition_v1.PartitionFromTravel(processes: Optional[dict] = None)
Bases:
episimlab.models.epi_model.EpiModelNine-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:
objectProvide a rate_E2P
- rate_E2P
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_E2P
dimensions : ()
- sigma
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : sigma
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_E2P
- class episimlab.models.partition_v1.RateE2Pa(*, tau, rate_E2P)
Bases:
objectProvide a rate_E2Pa
- rate_E2Pa
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_E2Pa
dimensions : ()
groups : edge_weight
- tau
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : tau
dimensions : ()
- rate_E2P
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : rate_E2P
- run_step()
- rate_E2Pa
- class episimlab.models.partition_v1.RateE2Py(*, tau, rate_E2P)
Bases:
objectProvide a rate_E2Py
- rate_E2Py
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_E2Py
dimensions : ()
groups : edge_weight
- tau
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : tau
dimensions : ()
- rate_E2P
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : rate_E2P
- run_step()
- rate_E2Py
- class episimlab.models.partition_v1.RateIa2R(*, gamma_Ia, state)
Bases:
objectProvide a rate_Ia2R
- rate_Ia2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ia2R
dimensions : ()
groups : edge_weight
- gamma_Ia
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma_Ia
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Ia2R
- class episimlab.models.partition_v1.RateIh2D(*, mu, nu, state, int_per_day)
Bases:
objectProvide a rate_Ih2D
- rate_Ih2D
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ih2D
dimensions : ()
groups : edge_weight
- mu
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : mu
dimensions : ()
- nu
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : nu
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Ih2D
- class episimlab.models.partition_v1.RateIh2R(*, gamma_Ih, nu, state, int_per_day)
Bases:
objectProvide a rate_Ih2R
- rate_Ih2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ih2R
dimensions : ()
groups : edge_weight
- gamma_Ih
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma_Ih
dimensions : ()
- nu
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : nu
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Ih2R
- class episimlab.models.partition_v1.RateIy2Ih(*, eta, pi, state, int_per_day)
Bases:
objectProvide a rate_Iy2Ih
- rate_Iy2Ih
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Iy2Ih
dimensions : ()
groups : edge_weight
- eta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : eta
dimensions : ()
- pi
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : pi
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Iy2Ih
- class episimlab.models.partition_v1.RateIy2R(*, gamma_Iy, pi, state)
Bases:
objectProvide a rate_Iy2R
- rate_Iy2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Iy2R
dimensions : ()
groups : edge_weight
- gamma_Iy
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma_Iy
dimensions : ()
- pi
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : pi
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Iy2R
- class episimlab.models.partition_v1.RatePa2Ia(*, rho_Ia, state)
Bases:
objectProvide a rate_Pa2Ia
- rate_Pa2Ia
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Pa2Ia
dimensions : ()
groups : edge_weight
- rho_Ia
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : rho_Ia
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Pa2Ia
- class episimlab.models.partition_v1.RatePy2Iy(*, rho_Iy, state)
Bases:
objectProvide a rate_Py2Iy
- rate_Py2Iy
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Py2Iy
dimensions : ()
groups : edge_weight
- rho_Iy
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : rho_Iy
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Py2Iy
- class episimlab.models.partition_v1.RateS2E(*, phi, state, beta, coords={})
Bases:
episimlab.foi.BaseFOIFOI that provides a rate_S2E
- phi
attr.Attribute Pairwise contact patterns
Variable properties:
type :
variableintent :
inglobal name : phi
dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- beta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : beta
dimensions : ()
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- rate_S2E
attr.Attribute No description given
Variable properties:
type :
variableintent :
outdimensions : ()
groups : edge_weight
- property I
- PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
- property S
- run_step()
- phi
- class episimlab.models.partition_v1.SetupComptGraph
Bases:
objectGenerate a 9-node compartment graph
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : compt_graph
- get_compt_graph() networkx.classes.digraph.DiGraph
- initialize()
- vis()
- compt_graph
- class episimlab.models.partition_v1.SetupCoords(*, travel_pat, compt_graph)
Bases:
objectInitialize 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_pat
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : travel_pat
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : compt_graph
- compt
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : compt_coords
dimensions : (‘compt’,)
groups : coords
- age
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : age_coords
dimensions : (‘age’,)
groups : coords
- risk
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : risk_coords
dimensions : (‘risk’,)
groups : coords
- vertex
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : vertex_coords
dimensions : (‘vertex’,)
groups : coords
- initialize()
- travel_pat
- class episimlab.models.partition_v1.SetupNuDefault(*, coords={})
Bases:
objectProvide a default value for nu
- nu
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : nu
dimensions : (‘age’,)
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- DIMS = ['age']
- property coords
- property dims
- initialize()
- nu
- class episimlab.models.partition_v1.SetupPiDefault(*, coords={})
Bases:
objectProvide a default value for pi
- pi
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : pi
dimensions : (‘risk’, ‘age’)
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- DIMS = ('risk', 'age')
- property coords
- property dims
- initialize()
- pi
- class episimlab.models.partition_v1.SetupState(*, coords={})
Bases:
objectInitialize state matrix
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : state
- property coords
- property dims
- initialize()
- _coords
episimlab.models.vaccine module
- class episimlab.models.vaccine.BetaReduction(*, beta, beta_reduction)
Bases:
object- beta
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : beta
- reduced_beta
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : reduced_beta
dimensions : ()
- beta_reduction
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : beta_reduction
dimensions : ()
- run_step()
- beta
- class episimlab.models.vaccine.RateE2P(*, sigma, state, int_per_day)
Bases:
objectProvide a rate_E2P
- rate_E2P
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_E2P
dimensions : ()
- sigma
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : sigma
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_E2P
- class episimlab.models.vaccine.RateE2Pa(*, tau, rate_E2P)
Bases:
objectProvide a rate_E2Pa
- rate_E2Pa
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_E2Pa
dimensions : ()
groups : edge_weight
- tau
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : tau
dimensions : ()
- rate_E2P
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : rate_E2P
- run_step()
- rate_E2Pa
- class episimlab.models.vaccine.RateE2Py(*, tau, rate_E2P)
Bases:
objectProvide a rate_E2Py
- rate_E2Py
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_E2Py
dimensions : ()
groups : edge_weight
- tau
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : tau
dimensions : ()
- rate_E2P
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : rate_E2P
- run_step()
- rate_E2Py
- class episimlab.models.vaccine.RateEv2P(*, sigma, state, int_per_day)
Bases:
objectProvide a rate_Ev2P
- rate_Ev2P
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ev2P
dimensions : ()
- sigma
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : sigma
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Ev2P
- class episimlab.models.vaccine.RateEv2Pa(*, tau_v, rate_Ev2P)
Bases:
objectProvide a `rate_Ev2Pa
- rate_Ev2Pa
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ev2Pa
dimensions : ()
groups : edge_weight
- tau_v
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : tau_v
dimensions : ()
- rate_Ev2P
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : rate_Ev2P
- run_step()
- rate_Ev2Pa
- class episimlab.models.vaccine.RateEv2Py(*, tau_v, rate_Ev2P)
Bases:
objectProvide a `rate_Ev2Py
- rate_Ev2Py
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ev2Py
dimensions : ()
groups : edge_weight
- tau_v
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : tau_v
dimensions : ()
- rate_Ev2P
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : rate_Ev2P
- run_step()
- rate_Ev2Py
- class episimlab.models.vaccine.RateIa2R(*, gamma_Ia, state)
Bases:
objectProvide a rate_Ia2R
- rate_Ia2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ia2R
dimensions : ()
groups : edge_weight
- gamma_Ia
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma_Ia
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Ia2R
- class episimlab.models.vaccine.RateIh2D(*, mu, nu, state, int_per_day)
Bases:
objectProvide a rate_Ih2D
- rate_Ih2D
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ih2D
dimensions : ()
groups : edge_weight
- mu
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : mu
dimensions : ()
- nu
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : nu
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Ih2D
- class episimlab.models.vaccine.RateIh2R(*, gamma_Ih, nu, state, int_per_day)
Bases:
objectProvide a rate_Ih2R
- rate_Ih2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Ih2R
dimensions : ()
groups : edge_weight
- gamma_Ih
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma_Ih
dimensions : ()
- nu
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : nu
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Ih2R
- class episimlab.models.vaccine.RateIy2Ih(*, eta, pi, state, int_per_day)
Bases:
objectProvide a rate_Iy2Ih
- rate_Iy2Ih
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Iy2Ih
dimensions : ()
groups : edge_weight
- eta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : eta
dimensions : ()
- pi
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : pi
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- int_per_day
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : int_per_day
- run_step()
- rate_Iy2Ih
- class episimlab.models.vaccine.RateIy2R(*, gamma_Iy, pi, state)
Bases:
objectProvide a rate_Iy2R
- rate_Iy2R
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Iy2R
dimensions : ()
groups : edge_weight
- gamma_Iy
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : gamma_Iy
dimensions : ()
- pi
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : pi
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Iy2R
- class episimlab.models.vaccine.RatePa2Ia(*, rho_Ia, state)
Bases:
objectProvide a rate_Pa2Ia
- rate_Pa2Ia
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Pa2Ia
dimensions : ()
groups : edge_weight
- rho_Ia
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : rho_Ia
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Pa2Ia
- class episimlab.models.vaccine.RatePy2Iy(*, rho_Iy, state)
Bases:
objectProvide a rate_Py2Iy
- rate_Py2Iy
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_Py2Iy
dimensions : ()
groups : edge_weight
- rho_Iy
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : rho_Iy
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- run_step()
- rate_Py2Iy
- class episimlab.models.vaccine.RateS2E(*, phi, state, beta, coords={})
Bases:
episimlab.foi.BaseFOIFOI that provides a rate_S2E
- phi
attr.Attribute Pairwise contact patterns
Variable properties:
type :
variableintent :
inglobal name : phi
dimensions : (‘age0’, ‘age1’, ‘risk0’, ‘risk1’, ‘vertex0’, ‘vertex1’)
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- beta
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : beta
dimensions : ()
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- rate_S2E
attr.Attribute No description given
Variable properties:
type :
variableintent :
outdimensions : ()
groups : edge_weight
- property I
- PHI_DIMS = ('age0', 'age1', 'risk0', 'risk1', 'vertex0', 'vertex1')
- property S
- TAGS = ('model::ElevenComptV1', 'FOI')
- run_step()
- phi
- class episimlab.models.vaccine.RateS2V(*, doses_delivered, eff_vaccine)
Bases:
objectVaccination dosage model
- rate_S2V
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : rate_S2V
dimensions : ()
groups : edge_weight
- doses_delivered
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : doses_delivered
- eff_vaccine
attr.Attribute No description given
Variable properties:
type :
variableintent :
inglobal name : eff_vaccine
dimensions : ()
- run_step()
- rate_S2V
- class episimlab.models.vaccine.RateV2Ev(*, state, coords={}, phi, beta)
Bases:
episimlab.foi.BaseFOIFOI that provides a rate_V2Ev
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- phi
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : phi
- beta
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : reduced_beta
- rate_V2Ev
attr.Attribute No description given
Variable properties:
type :
variableintent :
outdimensions : ()
groups : edge_weight
- I_COMPT_LABELS = ('Ia', 'Iy', 'Pa', 'Py')
- S_COMPT_LABELS = 'V'
- TAGS = ('model::ElevenComptV1', 'FOI')
- run_step()
- state
- class episimlab.models.vaccine.SetupComptGraph
Bases:
objectGenerate an 11-node compartment graph
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : compt_graph
- get_compt_graph() networkx.classes.digraph.DiGraph
- initialize()
- vis(path=None)
- compt_graph
- class episimlab.models.vaccine.SetupCoords(*, travel_pat, compt_graph)
Bases:
objectInitialize 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_pat
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : travel_pat
- compt_graph
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : compt_graph
- compt
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : compt_coords
dimensions : (‘compt’,)
groups : coords
- age
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : age_coords
dimensions : (‘age’,)
groups : coords
- risk
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : risk_coords
dimensions : (‘risk’,)
groups : coords
- vertex
attr.Attribute No description given
Variable properties:
type :
indexintent :
outglobal name : vertex_coords
dimensions : (‘vertex’,)
groups : coords
- initialize()
- travel_pat
- class episimlab.models.vaccine.SetupNuDefault(*, coords={})
Bases:
objectProvide a default value for nu
- nu
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : nu
dimensions : (‘age’,)
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- DIMS = ['age']
- property coords
- property dims
- initialize()
- nu
- class episimlab.models.vaccine.SetupPiDefault(*, coords={})
Bases:
objectProvide a default value for pi
- pi
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : pi
dimensions : (‘risk’, ‘age’)
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- DIMS = ('risk', 'age')
- property coords
- property dims
- initialize()
- pi
- class episimlab.models.vaccine.SetupState(*, coords={})
Bases:
objectInitialize state matrix
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
outglobal name : state
- property coords
- property dims
- initialize()
- _coords
- class episimlab.models.vaccine.SetupVaccineDoses(*, state, coords={})
Bases:
objectInitialize vaccine doses
- max_daily_doses
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : max_daily_doses
dimensions : (‘age’, ‘risk’)
- doses_delivered
attr.Attribute No description given
Variable properties:
type :
variableintent :
outglobal name : doses_delivered
dimensions : ()
- state
attr.Attribute No description given
Variable properties:
type :
globalintent :
inglobal name : state
- _coords
attr.Attribute Mapping of all variables that belong to group ‘coords’
Variable properties:
type :
group_dictintent :
indefault value : {}
- DIMS = ('age', 'risk')
- property S
- property coords
- property dims
- property eligible_pop
- initialize()
- run_step()
- max_daily_doses
- class episimlab.models.vaccine.Vaccine(processes: Optional[dict] = None)
Bases:
episimlab.models.epi_model.EpiModelNine-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
binomialmethod of adefault_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), thenm * n * ksamples are drawn. If size isNone(default), a single value is returned ifnandpare both scalars. Otherwise,np.broadcast(n, p).sizesamples 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
hypergeometricmethod of adefault_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), thenm * n * ksamples are drawn. If size isNone(default), a single value is returned if ngood, nbad, and nsample are all scalars. Otherwise,np.broadcast(ngood, nbad, nsample).sizesamples 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
xgood 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!