Implementation of Walker’s alias method.
This method generates a random sample from given probabilities \(p_1, \dots, p_n\) in \(O(1)\) time. It is more efficient than
choice(). This class works on both CPU and GPU.
パラメータ: probs (float list) – Probabilities of entries. They are normalized with sum(probs).
See: Wikipedia article
Generates a random sample based on given probabilities.
パラメータ: shape (tuple of int) – Shape of a return value. 戻り値: Returns a generated array with the given shape. If a sampler is in CPU mode the return value is a
numpy.ndarrayobject, and if it is in GPU mode the return value is a
Make a sampler GPU mode.