Deal with overflow in exp using numpy

前端 未结 6 1919
你的背包
你的背包 2020-11-29 07:24

Using numpy, I have this definition of a function:

def powellBadlyScaled(X):
    f1 = 10**4 * X[0] * X[1] - 1
    f2 = numpy.exp(-numpy.float(X[0])) + numpy         


        
6条回答
  •  情书的邮戳
    2020-11-29 08:04

    Maybe you can improve your algorithm by checking for which areas you get warnings (it will probably bellow certain values for X[ 0 ],X[ 1 ]), and replacing the result with a really big number. You need to see how your function behaves, I thing you should check e.g. exp(-x)+exp(-y)+x*y

提交回复
热议问题