类 AliasMethod
java.lang.Object
dev.utils.common.random.AliasMethod
detail: 随机概率采样算法
-
构造器概要
构造器构造器说明AliasMethod(List<Double> probabilities) Constructs a new AliasMethod to sample from a discrete distribution and hand back outcomes based on the probability distribution.AliasMethod(List<Double> probabilities, Random random) Constructs a new AliasMethod to sample from a discrete distribution and hand back outcomes based on the probability distribution. -
方法概要
-
构造器详细资料
-
AliasMethod
Constructs a new AliasMethod to sample from a discrete distribution and hand back outcomes based on the probability distribution.Given as input a list of probabilities corresponding to outcomes 0, 1, ..., n - 1, this constructor creates the probability and alias tables needed to efficiently sample from this distribution.
- 参数:
probabilities- The list of probabilities.
-
AliasMethod
Constructs a new AliasMethod to sample from a discrete distribution and hand back outcomes based on the probability distribution.Given as input a list of probabilities corresponding to outcomes 0, 1, ..., n - 1, along with the random number generator that should be used as the underlying generator, this constructor creates the probability and alias tables needed to efficiently sample from this distribution.
- 参数:
probabilities- The list of probabilities.random- The random number generator
-
-
方法详细资料
-
next
public int next()获取随机索引 ( 对应几率索引 ) Samples a value from the underlying distribution.- 返回:
- A random value sampled from the underlying distribution.
-