def toss(c, sh):
    """Return random samples of cumulative vector (1-D numpy array) c
    The samples are placed in an array of shape sh.
    Each element of array returned is an integer from 0 through n-1,
    where n is the length of c."""
    
    y = random(sh) #return array of uniform numbers (from 0 to 1) of shape sh
    x = searchsorted(c,y)

    return x
Return random samples of cumulative vector (1-D numpy array) c
    The samples are placed in an array of shape sh.
    Each element of array returned is an integer from 0 through n-1,
    where n is the length of c.
recipes/Python/498233_weighted_choice_short_easy_numpy/recipe-498233.py