:py:mod:`metacast.infection_seeding` ==================================== .. py:module:: metacast.infection_seeding .. autoapi-nested-parse:: 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 ~~~~~~~ .. autoapisummary:: metacast.infection_seeding._InfectionBranch metacast.infection_seeding.MultinomialSeeder .. py:class:: _InfectionBranch(name, outflows) .. py:method:: calculate_weighting(parameters) Calculate normalised weighting for each state. :param parameters: Dictionary of parameter values. :type parameters: dict {str: Number} :returns: **noramlised_weightings** -- Dictionary normalised weighting for each state. :rtype: dict {str: float} .. py:method:: seed_infections(n, parameters, rng=None) Make multinomial draw to select infectious stages of this branch to seed infection into. :param n: Number of infections to seed. :type n: int :param parameters: Dictionary of parameter values. :type parameters: dict {str: Number} :param rng: Random number generator to use. :type rng: numpy random number generator, optional. :returns: **draw_dict** -- Keys are states values are number of infections in state. :rtype: dict {str: int} .. py:class:: MultinomialSeeder(branch_info) Makes multinomial draws selecting an infectious hosts branch and then state. :param branch_info: 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). :type branch_info: nested dict .. attribute:: branches Infection branches that a host can be placed upon. :type: dict {str: InfectionBranch} .. attribute:: parameters Parameters (outflows) given in branch_info. :type: set of strings .. method:: seed_infections(n, branch_probability, parameters) Draw selection of states to place infected hosts. .. py:method:: set_seed(seed) Sets random number generator seed. :param seed: :type seed: int (>0) .. py:method:: _seed_branches(n, branch_probability) .. py:method:: seed_infections(n, branch_probability, parameters) Draw selection of states to place infected hosts. :param n: Number of infections to seed. :type n: int :param branch_probability: Probability of being on each infection branch. :type branch_probability: dict {string, float} :param parameters: Dictionary of parameter values. :type parameters: dict {str: Number} :returns: **infections_draw** -- Keys are infected states values are number of hosts in state. :rtype: dict {str: int}