Exemplo n.º 1
0
def calc_TLU_livestock(is_farming):
    """
    Calculates the livestock ownership (in Tropical Livestock Units) of this 
    household (based on analysis of 1996 CVFS data).
    """
    if is_farming:
        TLU = draw_from_prob_dist(rcParams['TLU_probs.farmer'])
    else:
        TLU = draw_from_prob_dist(rcParams['TLU_probs.nonfarmer'])
    # Given the way this prob dist was defined in R, if TLU is less than zero, 
    # it means that the household has 0 livestock units.
    if TLU < 0: TLU = 0
    return TLU
Exemplo n.º 2
0
def calc_first_birth_time(person):
    """
    Calculates the time from marriage until first birth for this person (not 
    used if the Ghimire and Axinn 2010 model is selected in rcparams.
    """
    first_birth_prob_dist = rcParams['prob.firstbirth.times']
    return int(draw_from_prob_dist(first_birth_prob_dist))
Exemplo n.º 3
0
def calc_des_num_children():
    "Calculates the desired number of children for this person."
    des_num_children_prob_dist = rcParams['prob.num.children.desired']
    # Use np.floor as the last number in the des_num_children prob dist (10) is 
    # not actually seen in the Chitwan data. It is included only as the 
    # right-hand bound of the distribution.
    return np.floor(draw_from_prob_dist(des_num_children_prob_dist))
Exemplo n.º 4
0
def calc_spouse_age_diff(person):
    """
    This function draws the age difference between this person and their 
    spouse based on the observed probability distribution. Note that the age 
    difference is defined as male's age - woman's age, so positive age 
    differences should be subtracted from men's ages to get their spouse age, and 
    added to women's.
    """
    return draw_from_prob_dist(rcParams['spousechoice.male.agediff'])
Exemplo n.º 5
0
def calc_inmigrant_household_ethnicity(as_integer=False):
    ethnicity = int(draw_from_prob_dist(rcParams['inmigrant_HH.prob.ethnicity']))
    if not as_integer:
        if ethnicity == 1:
            ethnicity = "HighHindu"
        elif ethnicity == 2:
            ethnicity = "HillTibeto"
        elif ethnicity == 3:
            ethnicity = "LowHindu"
        elif ethnicity == 4:
            ethnicity = "Newar"
        elif ethnicity == 5:
            ethnicity = "TeraiTibeto"
        else:
            logger.critical("Undefined ethnicity %s drawn for new inmigrant household"%ethnicity)
    return ethnicity
Exemplo n.º 6
0
def calc_migration_length(person, BURN_IN):
    """
    Calculated the length of a migration from a probability distribution.

    Note: The BURN_IN variable is used in the initialization of a model run to 
    model migrations that occurred prior to the beginning of the data 
    collection. Permanent migrations are not allowed during this burn-in 
    period.
    """
    # First decide if it is permanent, according to the 
    # "prob.migration.length.permanent" parameter:
    if not BURN_IN and np.random.rand() < rcParams['prob.migration.length.permanent']:
        # TODO: Instead of very long term in agent-store, just remove them from 
        # the model with the make_permanent_outmigration method.
        return 99999999
    mig_length_prob_dist = rcParams['prob.migration.lengths']
    # Use ceil here so the minimum value is 1, and the maximum value is 36
    return np.ceil(draw_from_prob_dist(mig_length_prob_dist))
Exemplo n.º 7
0
def calc_hh_area():
    "Calculates the area of this household."
    hh_area_prob_dist = rcParams['lulc.area.hh']
    return draw_from_prob_dist(hh_area_prob_dist)
Exemplo n.º 8
0
def calc_total_possessions():
    """
    Calculates the number of possessions this household owns (based on analysis 
    of 1996 CVFS data).
    """
    return np.floor(draw_from_prob_dist(rcParams['total_possessions_probs']) + 1)
Exemplo n.º 9
0
def calc_birth_interval():
    "Calculates the birth interval for this person."
    birth_interval_prob_dist = rcParams['prob.birth.intervals']
    return np.floor(draw_from_prob_dist(birth_interval_prob_dist))
Exemplo n.º 10
0
def calc_inmigrant_household_size():
    return int(draw_from_prob_dist(rcParams['inmigrant_HH.prob.hh_size']))
Exemplo n.º 11
0
def calc_num_inmigrant_households():
    """
    Draws the number of in migrating households in a given month based on an 
    empirical probability distribution.
    """
    return int(draw_from_prob_dist(rcParams['inmigrant_HH.prob.num_HHs']))