def random_match(idx_hhs, idx_blds): resunits = np.array([np.maximum(np.ones(idx_blds.size),(building_set['residential_units'][idx_blds])),]*idx_hhs.size) row_sums = resunits.sum(axis=1) probabilities = (resunits) / (np.array([(row_sums),]*idx_blds.size).transpose()) choices = random_choices().run(probabilities) counter = 0 for choice in choices: household_set['building_id'][idx_hhs[counter]] = building_set['building_id'][idx_blds[choice]] counter += 1
def random_match(idx_estabs, idx_blds): units = np.array([np.maximum(np.ones(idx_blds.size),(building_set['non_residential_sqft'][idx_blds])),]*idx_estabs.size) row_sums = units.sum(axis=1) probabilities = (units) / (np.array([(row_sums),]*idx_blds.size).transpose()) choices = random_choices().run(probabilities) counter = 0 for choice in choices: establishment_set['building_id'][idx_estabs[counter]] = building_set['building_id'][idx_blds[choice]] counter += 1