def discrete_single_draw( ps, randstate=np.random):
  totals = np.cumsum(ps)
  return np.searchsorted(totals, randstate.rand()*totals[-1])
Given vector of K positive real weights "ps",
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/util/RandUtil.py/discrete_single_draw