Scipy minimize fmin - problems with syntax


I have a function which takes several arguments (one array and two floats) and returns a scalar (float). Now I want to minimize this function by varying two of the arguments: the two floats. The array is "unpacked" inside the function at its contents (arrays and floats) are then used.

How can this be done using SciPy's fmin function? I am having a very hard time figuring out the right syntax for this..

The function is something like:

def func(x, y, data)
    result = ...x...y...data1...data2... #result is a scalar (float)
    return result

What should scipy.optimize.fmin look like in this case?

optimize.fmin(func, ???)

Many thanks in advance!

All the best, p.p.

scipy assumes that the arguments are in an array. You can define a helper function:

def helper(xy):
    return func(xy[0], xy[1], data)

and minimize it with optimize.fmin:

optimize.fmin(helper, np.array([x0, y0]), ...)