def pf(q, eps=1.0, sensitivity=1.0, prng=np.random, monotonic=False):
    coef = (1.0 if monotonic else 0.5)
    q = (q - q.max())
    p = np.exp((((coef * eps) / sensitivity) * q))
    for i in prng.permutation(p.size):
        if (prng.rand() <= p[i]):
            return i
def pf(q, eps=1.0, sensitivity=1.0, prng=np.random, monotonic=False):
    coef = (1.0 if monotonic else 0.5)
    q = (q - q.max())
    p = np.exp((((coef * eps) / sensitivity) * q))
    for i in prng.permutation(p.size):
        if (prng.rand() <= p[i]):
            return i