You are viewing a single comment's thread. Return to all comments →
Easy way to sample from categorical:
def sample_cat(dice_probs): g = [-log(-log(uniform(0,1))) + log(p) for _, p in zip(range(6), dice_probs)] sample = g.index(max(g)) return sample
Ref: https://en.wikipedia.org/wiki/Categorical_distribution#Sampling_via_the_Gumbel_distribution
Seems like cookies are disabled on this browser, please enable them to open this website
Markov's Snakes And Ladders
You are viewing a single comment's thread. Return to all comments →
Easy way to sample from categorical:
Ref: https://en.wikipedia.org/wiki/Categorical_distribution#Sampling_via_the_Gumbel_distribution