Код: Выделить всё
categorical_distributions = np.array([
[.1, .3, .6],
[.2, .4, .4],
])
_, n = categorical_distributions.shape
np.array([np.random.choice(n, p=row)
for row in categorical_distributions])
Подробнее здесь: https://stackoverflow.com/questions/477 ... along-an-a
Мобильная версия