june.demography.demography.AgeSexGenerator

class june.demography.demography.AgeSexGenerator(age_counts: list, sex_bins: list, female_fractions: list, ethnicity_age_bins: list = None, ethnicity_groups: list = None, ethnicity_structure: list = None, socioecon_index_value: int = None, max_age=99)

age_counts is an array where the index in the array indicates the age, and the value indicates the number of counts in that age. sex_bins are the lower edges of each sex bin where we have a fraction of females from census data, and female_fractions are those fractions. ethnicity_age_bins are the lower edges of the age bins that ethnicity data is in ethnicity_groups are the labels of the ethnicities which we have data for. ethnicity_structure are (integer) ratios of the ethnicities, for each age bin. the sum of this strucutre need NOT be the total number of people returned by the generator. Example:

age_counts = [1, 2, 3] means 1 person of age 0, 2 people of age 1 and 3 people of age 2. sex_bins = [1, 3] defines two bins: (0,1) and (3, infinity) female_fractions = [0.3, 0.5] means that between the ages 0 and 1 there are 30% females,

and there are 50% females in the bin 3+ years

ethnicity_age_bins - see sex_bins ethnicity_groups = [‘A’,’B’,’C’] - there are three types of ethnicities that we are

assigning here.

ethnicity_structure = [[0,5,3],[2,3,0],…] in the first age bin, we assign people

ethnicities A:B:C with probability 0:5:3, and so on.

socioecon_index = 6 means this area belongs to the 6th decile in the index

of multiple deprivation.

Given this information we initialize two generators for age and sex, that can be accessed through gen = AgeSexGenerator().age() and AgeSexGenerator().sex().

age_counts

A list or array with the counts for each age.

female_fractions

A dictionary where keys are age intervals like “int-int” and the values are the fraction of females inside each age bin.

__init__(age_counts: list, sex_bins: list, female_fractions: list, ethnicity_age_bins: list = None, ethnicity_groups: list = None, ethnicity_structure: list = None, socioecon_index_value: int = None, max_age=99)

age_counts is an array where the index in the array indicates the age, and the value indicates the number of counts in that age. sex_bins are the lower edges of each sex bin where we have a fraction of females from census data, and female_fractions are those fractions. ethnicity_age_bins are the lower edges of the age bins that ethnicity data is in ethnicity_groups are the labels of the ethnicities which we have data for. ethnicity_structure are (integer) ratios of the ethnicities, for each age bin. the sum of this strucutre need NOT be the total number of people returned by the generator. Example:

age_counts = [1, 2, 3] means 1 person of age 0, 2 people of age 1 and 3 people of age 2. sex_bins = [1, 3] defines two bins: (0,1) and (3, infinity) female_fractions = [0.3, 0.5] means that between the ages 0 and 1 there are 30% females,

and there are 50% females in the bin 3+ years

ethnicity_age_bins - see sex_bins ethnicity_groups = [‘A’,’B’,’C’] - there are three types of ethnicities that we are

assigning here.

ethnicity_structure = [[0,5,3],[2,3,0],…] in the first age bin, we assign people

ethnicities A:B:C with probability 0:5:3, and so on.

socioecon_index = 6 means this area belongs to the 6th decile in the index

of multiple deprivation.

Given this information we initialize two generators for age and sex, that can be accessed through gen = AgeSexGenerator().age() and AgeSexGenerator().sex().

age_counts

A list or array with the counts for each age.

female_fractions

A dictionary where keys are age intervals like “int-int” and the values are the fraction of females inside each age bin.

age() → int
ethnicity() → str
classmethod from_age_sex_bins(men_age_dict: dict, women_age_dict: dict, exponential_decay: int = 2)

Initializes age and sex generator (no ethnicity and socioecon_index for now) from a dictionary containing age bins and counts for man and woman. An example of the input is men_age_dict = {“0-2” : 10, “2-99”: 50}. If the bin contains the 99 value at the end, the age will be sampled with an exponential decay of the form e^(-x/exponential_decay).

sex() → str
socioecon_index() → int