2

I have been trying to find the min of this function but i cant seem to get the proper syntax. y2 and y1a are numpy arrays im trying to pass to my lambda function and x is my third variable used by fmin.

        y2 = numpy.array(Apple[i:i+len(Leal)])
        y1 = Leal

        y1a = y1 + dif

        y = lambda x, y2, y1a: sum(abs((y2)+x)-y1a)
        emin = fmin(y,0)

Any help would be great.

4

1 回答 1

1

您的 y 函数需要 3 个值,但 fmin 只提供一个...

您需要提供一个数组作为初始估计值,或者提供其他参数作为args

http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fmin.html

假设您需要后者:

fmin(y, 0, args=(y2, y1a))
于 2013-04-17T13:14:13.570 回答