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 overwritten

  • pop (str) – string with the code name of the population being overwritten

  • progs (dict) – a dict containing {prog_name:outcome} with the single program outcomes

  • cov_interaction (str) – one of ‘additive’, ‘random’, ‘nested’

  • imp_interaction (str) – a parsable string like 'Prog1+Prog2=10,Prog2+Prog3=20' with the interaction outcomes

  • uncertainty – a scalar standard deviation for the outcomes

  • baseline – the zero coverage baseline value

Attributes

n_progs

Return the number of programs

Methods

compute_impact_interaction

Return the output for a given combination of programs

get_outcome

Return parameter value given program coverages

sample

Perturb the values entered in the databook

update_outcomes

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:

float

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. The Covout.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 a np.array (such that that generated by ProgramSet.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

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 a constant argument.

Return type:

None

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 :rtype: None

  1. Sorting the programs by outcome value

  2. Compute the deltas relative to baseline

  3. Pre-compute the outcomes associated with every possible combination of programs