class_docstr: Vose's Alias Method.
      
docstr: Initialize the alias table according to the input distribution
  Arg:
      distribution: the input distribution.
docstr_tok: ["Initialize","the","alias","table","according","to","the","input","distribution","Arg",":","distribution",":","the","input","distribution","."]
code: def initialize(self, distribution):
      """Initialize the alias table according to the input distribution
      Arg:
          distribution: the input distribution.
      """
      size = distribution.shape[0]
      self.__alias = np.zeros(size, dtype=np.int64)
      self.__prob = np.zeros(size)
      sum_ = np.sum(distribution)
      p = distribution / sum_ * size  # Scale up probability.
      large, small = [], []
      for i, p_ in enumerate(p):
          if p_ < 1.0:
              small.append(i)
          else:
              large.append(i)
  
      while large and small:
          l = small[0]
          g = large[0]
          small.pop(0)
          large.pop(0)
          self.__prob[l] = p[l]
          self.__alias[l] = g
          p[g] = p[g] + p[l] - 1  # A more numerically stable option.
          if p[g] < 1.0:
              small.append(g)
          else:
              large.append(g)
  
      while large:
          g = large[0]
          large.pop(0)
          self.__prob[g] = 1.0
  
      while small:
          l = small[0]
          small.pop(0)
          self.__prob[l] = 1.0
  
file_path: PaddleHub/modules/text/language_model/lda_news/vose_alias.py
imports: import numpy
  from lda_news.util import rand, rand_k
label_desc: Use image node_id 2 for calling the VoseAlias obj's underlying member method code with example usage: obj.initialize(distribution) without return types