code: def rcategorical(p, size=None):
      
      out = flib.rcat(p, np.random.random(size=size))
      if sum(out.shape) == 1:
          return out.squeeze()
      else:
          return out
docs: Categorical random variates.