metacast.infection_seeding

Creation:

Author: Martin Grunnill Date: 2022/09/13

Description: Classes for Multnomial random draw seeding of infections.

Classes

MultnomialSeeder

Makes multinomial draws selecting an infectious hosts branch and then state.

Module Contents

Classes

_InfectionBranch

MultinomialSeeder

Makes multinomial draws selecting an infectious hosts branch and then state.

class metacast.infection_seeding._InfectionBranch(name, outflows)
calculate_weighting(parameters)

Calculate normalised weighting for each state.

Parameters:

parameters (dict {str: Number}) – Dictionary of parameter values.

Returns:

noramlised_weightings – Dictionary normalised weighting for each state.

Return type:

dict {str: float}

seed_infections(n, parameters, rng=None)

Make multinomial draw to select infectious stages of this branch to seed infection into.

Parameters:
  • n (int) – Number of infections to seed.

  • parameters (dict {str: Number}) – Dictionary of parameter values.

  • rng (numpy random number generator, optional.) – Random number generator to use.

Returns:

draw_dict – Keys are states values are number of infections in state.

Return type:

dict {str: int}

class metacast.infection_seeding.MultinomialSeeder(branch_info)

Makes multinomial draws selecting an infectious hosts branch and then state.

Parameters:

branch_info (nested dict) –

First level keys are branches (str).

Second level keys are states (str or ints) and values are the names of parameters controlling outflows for those states (str).

branches

Infection branches that a host can be placed upon.

Type:

dict {str: InfectionBranch}

parameters

Parameters (outflows) given in branch_info.

Type:

set of strings

seed_infections(n, branch_probability, parameters)

Draw selection of states to place infected hosts.

set_seed(seed)

Sets random number generator seed.

Parameters:

seed (int (>0)) –

_seed_branches(n, branch_probability)
seed_infections(n, branch_probability, parameters)

Draw selection of states to place infected hosts.

Parameters:
  • n (int) – Number of infections to seed.

  • branch_probability (dict {string, float}) – Probability of being on each infection branch.

  • parameters (dict {str: Number}) – Dictionary of parameter values.

Returns:

infections_draw – Keys are infected states values are number of hosts in state.

Return type:

dict {str: int}