def max_epsilon_ratio(q):

    def foo(eps):
        err = expected_error(q, eps, pf_pmf)
        eps2 = expected_epsilon(q, err, [eps, (2 * eps)])
        return ((- eps2) / eps)
    br = bracket(foo, 0.001, 1.0)[0:3]
    ans = minimize_scalar(foo, bracket=br, method='brent')
    eps0 = ans.x
    err = expected_error(q, eps0, pf_pmf)
    eps1 = expected_epsilon(q, err, [eps0, (2 * eps0)])
    return (eps0, err, eps1)
def max_epsilon_ratio(q):

    def foo(eps):
        err = expected_error(q, eps, pf_pmf)
        eps2 = expected_epsilon(q, err, [eps, (2 * eps)])
        return ((- eps2) / eps)
    br = bracket(foo, 0.001, 1.0)[0:3]
    ans = minimize_scalar(foo, bracket=br, method='brent')
    eps0 = ans.x
    err = expected_error(q, eps0, pf_pmf)
    eps1 = expected_epsilon(q, err, [eps0, (2 * eps0)])
    return (eps0, err, eps1)