I have a simple equation that I plotted via
def chernoff_bound(beta):
return 0.5 * np.exp(-beta * (1-beta))
betas = np.arange(0, 1, 0.01)
c_bound = cher
The second argument of optimize.minimize
is an initial guess -- your guess for the minimum x
-value that you wish optimize.minimize
to find. So, for example,
import numpy as np
from scipy import optimize
x0 = 0.1
fun = lambda x: 0.5 * np.exp(-x * (1-x))
res = optimize.minimize(fun, x0, method='Nelder-Mead')
print(res)
yields
status: 0
nfev: 36
success: True
fun: 0.38940039153570244
x: array([ 0.5])
message: 'Optimization terminated successfully.'
nit: 18
x0
need not always be a scalar. It could be an array -- it depends on fun
. In the above example, x0 = np.array([0.1])
would also work. The key point is that for whatever you guess, fun(x0)
should be a scalar.