我正在创建一个随机生成婴儿出生体重的数组。我想使用numpy.random创建第二个数组,该数组在1年后随机选择婴儿的处置方式。我遇到的困难是我想要两个数组之间的关联。出生体重越低,一年后死亡的机会越高(23%)。
任何想法?
#Setting Parameters for birthweight, low = 400g, High = 1500g
bw = np.random.randint(400, 1500, size=100) #this function draws random
numbers from a uniform distribution
dip = np.random.choice(["Died", "At Home", "Still Hos", "Unknown"], 100, p=
[0.2, 0.1, 0.1, 0.6])
# Populating the Dataset
df = pd.DataFrame({ "Birthweight" : bw, "Disposition" : dip})
df