def pf_pmf(q, eps=1.0, sensitivity=1.0, monotonic=False):
    coef = (1.0 if monotonic else 0.5)
    p = np.exp((((coef * eps) / sensitivity) * (q - q.max())))
    n = q.size
    subsets = np.zeros(n)
    curr = np.cumsum(p)
    subsets[0] = curr[(- 1)]
    for j in range(1, n):
        curr[j:] = np.cumsum((curr[(j - 1):(- 1)] * p[j:]))
        subsets[j] = curr[(- 1)]
    coef = ((((np.arange(n) % 2) * 2) - 1) / (np.arange(n) + 2))
    ans = np.zeros(n)
    for i in range(n):
        new = np.copy(subsets)
        new[0] -= p[i]
        for j in range(1, n):
            new[j] -= (new[(j - 1)] * p[i])
        ans[i] = (p[i] * (1 + (new @ coef)))
    return ans
def pf_pmf(q, eps=1.0, sensitivity=1.0, monotonic=False):
    coef = (1.0 if monotonic else 0.5)
    p = np.exp((((coef * eps) / sensitivity) * (q - q.max())))
    n = q.size
    subsets = np.zeros(n)
    curr = np.cumsum(p)
    subsets[0] = curr[(- 1)]
    for j in range(1, n):
        curr[j:] = np.cumsum((curr[(j - 1):(- 1)] * p[j:]))
        subsets[j] = curr[(- 1)]
    coef = ((((np.arange(n) % 2) * 2) - 1) / (np.arange(n) + 2))
    ans = np.zeros(n)
    for i in range(n):
        new = np.copy(subsets)
        new[0] -= p[i]
        for j in range(1, n):
            new[j] -= (new[(j - 1)] * p[i])
        ans[i] = (p[i] * (1 + (new @ coef)))
    return ans