code: def probchoice(items, probs, bincount=1000):
      """
      Splits the interval 0.0-1.0 in proportion to probs
      then finds where each random.random() choice lies
      """
  
      prob_accumulator = 0
      accumulator = []
      for p in probs:
          prob_accumulator += p
          accumulator.append(prob_accumulator)
  
      while True:
          r = random.random()
          yield items[bisect.bisect(accumulator, r)]
  
imports: import random, bisect
label_desc: Use image node_id 1 for calling a global function with example usage: probchoice(items, probs, bincount) without return types