Beispiel #1
0
    test_n_single_ages(1e4, location, state_location, country_location)
    test_multiple_ages(1e4, location, state_location, country_location)
    test_resample_age()
    test_generate_household_sizes()
    test_generate_household_sizes_from_fixed_pop_size()
    test_generate_all_households()
    test_get_totalpopsizes_from_household_sizes()
    test_assign_uids_by_homes()
    test_get_school_enrollment_rates_path()
    test_get_uids_in_school(location, state_location, country_location)
    test_send_students_to_school(n=10000,
                                 location='seattle_metro',
                                 state_location='Washington',
                                 country_location='usa')
    # test_get_uids_potential_workers()
    # test_assign_rest_of_workers()
    test_generate_workplace_sizes()
    test_generate_school_sizes()

    ages, sexes = sp.get_usa_age_sex_n(datadir, location, state_location,
                                       country_location, 1e2)
    print(ages, sexes)

    # country_location = 'Algeria'
    # age_brackets_filepath = sp.get_census_age_brackets_path(sp.datadir,country_location)
    # age_brackets = sp.get_age_brackets_from_df(age_brackets_filepath)
    # print(age_brackets)
    sc.toc()

print('Done.')
create_homes = False
if create_homes:
    household_size_distr = sp.get_household_size_distr(datadir, location,
                                                       state_location,
                                                       country_location,
                                                       use_bayesian)
    print(household_size_distr)

    Nhomes_to_sample_smooth = 100000
    hh_sizes = sp.generate_household_sizes(Nhomes_to_sample_smooth,
                                           household_size_distr)
    totalpop = sp.get_totalpopsize_from_household_sizes(hh_sizes)

    # hh_sizes = sp.generate_household_sizes(Nhomes,household_size_distr)

    syn_ages, syn_sexes = sp.get_usa_age_sex_n(location, state_location,
                                               totalpop)
    syn_age_count = Counter(syn_ages)
    syn_age_distr = sp.norm_dic(Counter(syn_ages))

    N = Nhomes
    hh_sizes = sp.generate_household_sizes_from_fixed_pop_size(
        N, household_size_distr)
    totalpop = sp.get_totalpopsize_from_household_sizes(hh_sizes)

    print(totalpop, 'pop')

    hha_df = sp.get_household_head_age_by_size_df(datadir, country_location,
                                                  use_bayesian)
    hha_brackets = sp.get_head_age_brackets(datadir, country_location,
                                            use_bayesian)
    hha_by_size = sp.get_head_age_by_size_distr(datadir, country_location,
Beispiel #3
0
create_homes = True
# create_homes = False
if create_homes:
    household_size_distr = sp.get_household_size_distr(datadir, location,
                                                       state_location,
                                                       country_location)
    print('size distr', household_size_distr)

    Nhomes_to_sample_smooth = 100000
    hh_sizes = sp.generate_household_sizes(Nhomes_to_sample_smooth,
                                           household_size_distr)
    totalpop = sp.get_totalpopsize_from_household_sizes(hh_sizes)
    # hh_sizes = sp.generate_household_sizes(Nhomes,household_size_distr)

    syn_ages, syn_sexes = sp.get_usa_age_sex_n(datadir, location,
                                               state_location,
                                               country_location, totalpop)
    syn_age_count = Counter(syn_ages)
    syn_age_distr = sp.norm_dic(Counter(syn_ages))

    N = Nhomes
    hh_sizes = sp.generate_household_sizes_from_fixed_pop_size(
        N, household_size_distr)
    totalpop = sp.get_totalpopsize_from_household_sizes(hh_sizes)

    print(totalpop, 'pop')

    hha_df = sp.get_household_head_age_by_size_df(datadir, state_location,
                                                  country_location)
    hha_brackets = sp.get_head_age_brackets(datadir,
                                            country_location=country_location)