Back to problems

Weighted Sampling from Unnormalized Probabilities

Algorithm · LinkedIn · Medium

Requirements Create a sampler that chooses an index from 0 through N-1 according to the probabilities supplied in an array. A typical interface is: This may be presented in several equivalent ways: Simulate a biased die with N faces, where the face probabilities come from applying softmax to a set of logits. Sample from category weights produced by a recommender system or ranking model. Given a multinomial parameter vector, generate draws for a later calibration stage in an…

Checking your access…