get_aggregate_matrix#
- get_aggregate_matrix(matrix, age_by_brackets)[source]#
Aggregate a symmetric matrix to fewer age brackets. Do not use for homogeneous mixing matrix.
- Parameters:
matrix (np.ndarray) – A symmetric age contact matrix.
age_by_brackets (dict) – A dictionary mapping age to the age bracket range it falls within.
- Returns:
A symmetric contact matrix (
np.ndarray
) aggregated to age brackets.
Example
age_brackets = sp.get_census_age_brackets(sp.settings_config.datadir,state_location='Washington',country_location='usa') age_by_brackets = sp.get_age_by_brackets(age_brackets) aggregate_age_count = sp.get_aggregate_ages(age_count, age_by_brackets) aggregate_matrix = symmetric_matrix.copy() aggregate_matrix = sp.get_aggregate_matrix(aggregate_matrix, age_by_brackets_dic) asymmetric_matrix = sp.get_asymmetric_matrix(aggregate_matrix, aggregate_age_count)