类 AliasMethod

java.lang.Object
dev.utils.common.random.AliasMethod

public final class AliasMethod extends Object
detail: 随机概率采样算法
作者:
Keith Schwarz
另请参阅:
  • 构造器详细资料

    • AliasMethod

      public AliasMethod(List<Double> probabilities)
      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

      public 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.

      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.