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) data1=data data2=data[...] ... ... result = ...x...y...data1...data2... #result is a scalar (float) return result
scipy.optimize.fmin look like in this case?
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, xy, data)
and minimize it with
optimize.fmin(helper, np.array([x0, y0]), ...)