def expected_error(q, eps, pmf=em_pmf):
    ans = (q.max() - (pmf(q, eps) @ q))
    maxerr = (q.max() - q.mean())
    if ((ans > maxerr) or (ans < 0)):
        return maxerr
    return ans
def expected_error(q, eps, pmf=em_pmf):
    ans = (q.max() - (pmf(q, eps) @ q))
    maxerr = (q.max() - q.mean())
    if ((ans > maxerr) or (ans < 0)):
        return maxerr
    return ans