atomica.programs.Covout¶
- class atomica.programs.Covout(par, pop, progs, cov_interaction=None, imp_interaction=None, uncertainty=0.0, baseline=0.0)[source]¶
Bases:
object
Store and compute program outcomes
The
Covout
object is responsible for storing the- Parameters
par (
str
) – string with the code name of the parameter being overwrittenpop (
str
) – string with the code name of the population being overwrittenprogs (
dict
) – a dict containing{prog_name:outcome}
with the single program outcomescov_interaction (
Optional
[str
]) – one of ‘additive’, ‘random’, ‘nested’imp_interaction (
Optional
[str
]) – a parsable string like'Prog1+Prog2=10,Prog2+Prog3=20'
with the interaction outcomesuncertainty – a scalar standard deviation for the outcomes
baseline – the zero coverage baseline value
Attributes
Return the number of programs
Methods
Return the output for a given combination of programs
Return parameter value given program coverages
Perturb the values entered in the databook
Update cache when outcomes change
- compute_impact_interaction(progs)[source]¶
Return the output for a given combination of programs
The outcome for various combinations of programs is cached prior to running the model. This function retrieves the appropriate delta given a boolean array flagging which programs are active
- Parameters
progs (
array
) – A numpy boolean array, with length equal to the number of programs- Return type
- Returns
The delta value corresponding to the specified combination of programs
- get_outcome(prop_covered)[source]¶
Return parameter value given program coverages
The
Covout
object contains a set of programs and outcomes. TheCovout.get_outcome()
method returns the outcome value associated for coverage of each program. Don’t forget that any given Covout instance is already specific to a(par,pop)
combination- Parameters
prop_covered – A dict with
{prog_name:coverage}
containing at least all of the programs in self.progs. Note that coverage is expected to be anp.array
(such that that generated byProgramSet.get_prop_coverage()
). However, because the modality calculations only work for scalars, only the first entry in the array will be used. Note that the coverage in this dictionary should be dimensionless.- Returns
A scalar outcome (of type np.double or similar i.e. _not_ an array)
- property n_progs: int¶
Return the number of programs
- Return type
- Returns
The number of programs with defined outcomes (usually this is a subset of all available programs)
- sample()[source]¶
Perturb the values entered in the databook
The
Covout
instance is modified in-place. Note that the program outcomes are scalars that do not vary over time - therefore,Covout.sample()
does not have aconstant
argument.- Return type
- update_outcomes()[source]¶
Update cache when outcomes change
This method should be called whenever the baseline, program outcomes, or interaction outcomes change. It updates the internal cache so that get_outcome() uses the correct values. It’s responsible for
Sorting the programs by outcome value
Compute the deltas relative to baseline
Pre-compute the outcomes associated with every possible combination of programs
- Return type