From abc6251a98c2d34e09f7e7f59a49ffceaa7ffcda Mon Sep 17 00:00:00 2001 From: DianeCM Date: Fri, 28 Apr 2023 04:01:51 -0400 Subject: [PATCH] Members per home variable --- data_distribution.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/data_distribution.py b/data_distribution.py index 10dab30..6bf1b9b 100644 --- a/data_distribution.py +++ b/data_distribution.py @@ -1,4 +1,4 @@ - +import random as random # work-related distributions total_employees = 47100 @@ -83,3 +83,18 @@ # the third high school and the last higher education. enrollment_distribution = [x for x in [1952, 9995, 24713, 10440]] total_enrollment = 47100 + +#number of members per home variable. +#Position i represents the number of homes with i+1 members +total=3721042 +prob_density=[ elem/total for elem in [688205, 956925, 950687,667271, 281969,110739,41575,16434,7237]] + +class var_generator: + def __init__(self,prob_density): + self.prob_density= prob_density + def generate(self): + x=random.random() + current=0 + for i in range(len(self.prob_density)): + current+=prob_density[i] + if x < current: return i+1