code: def sample_outcomes(probs, n):
      
      dist = np.cumsum(probs)
      rs = np.random.rand(n)
      return np.array([(np.where(r < dist)[0][0]) for r in rs])
docs: For a discrete probability distribution ``probs`` with outcomes 0, 1, ..., k-1 draw ``n``
      random samples.
  
      :param list probs: A list of probabilities.
      :param Number n: The number of random samples to draw.
      :return: An array of samples drawn from distribution probs over 0, ..., len(probs) - 1
      :rtype: numpy.ndarray