networks

networks

Custom network classes for direct transmission

Classes

Name Description
CommunityNet Create an age-assortative network based on a 2D age-mixing pattern.
HouseholdNet WIP: Microstructured connectivity between agents. Households can change in size

CommunityNet

networks.CommunityNet(pars=None, **kwargs)

Create an age-assortative network based on a 2D age-mixing pattern.

Methods

Name Description
add_pairs Generate contacts using a specific age mixing pattern
estimate_age_mixing_density Perform a 2d KDE on rither ages or age groups of p1 and p2
get_age_groups Find the age group each person belongs to, and the size of each group
get_contact_rates Get average number of total number of contacts per day, per age group
plot_age_mixing_density Plot the age-group by age-group density matrix
add_pairs
networks.CommunityNet.add_pairs()

Generate contacts using a specific age mixing pattern

estimate_age_mixing_density
networks.CommunityNet.estimate_age_mixing_density(to_plot=None)

Perform a 2d KDE on rither ages or age groups of p1 and p2

get_age_groups
networks.CommunityNet.get_age_groups()

Find the age group each person belongs to, and the size of each group

get_contact_rates
networks.CommunityNet.get_contact_rates()

Get average number of total number of contacts per day, per age group (num age groups x 1), and a matrix of the average proportion of contacts per day of each age group (num age groups x num age groups).

plot_age_mixing_density
networks.CommunityNet.plot_age_mixing_density(to_plot=None)

Plot the age-group by age-group density matrix

HouseholdNet

networks.HouseholdNet(pars=None, **kwargs)

if one of their members die.

Methods

Name Description
add_pairs Generate contacts
get_contacts Efficiently generate contacts
get_households Given a population of size n_agents, and a household size distribution
get_source Optimized helper function for getting contacts
add_pairs
networks.HouseholdNet.add_pairs()

Generate contacts

get_contacts
networks.HouseholdNet.get_contacts(inds, n_contacts)

Efficiently generate contacts

Note that because of the shuffling operation, each person is assigned 2N contacts (i.e. if a person has 5 contacts, they appear 5 times in the ‘source’ array and 5 times in the ‘target’ array). Therefore, the number_of_contacts argument to this function should be HALF of the total contacts a person is expected to have, if both the source and target array outputs are used (e.g. for social contacts)

adjusted_number_of_contacts = np.round(number_of_contacts / 2).astype(cvd.default_int)

Whereas for asymmetric contacts (e.g. staff-public interactions) it might not be necessary

Parameters
Name Type Description Default
inds List/array of person indices required
number_of_contacts List/array the same length as inds with the number of unidirectional required

Returns: Two arrays, for source and target

get_households
networks.HouseholdNet.get_households()

Given a population of size n_agents, and a household size distribution calculate the number of households of each size.

Returns
Name Type Description
An array with the count of households of size ‘s’ at .
get_source
networks.HouseholdNet.get_source(inds, n_contacts)

Optimized helper function for getting contacts