我正在尝试对f的不同值执行f(x)= 42 * log(2)* 2 ^( - t)从x = 0到t的积分,如下所示:
import numpy as np
from scipy.integrate import quad
reward = lambda t: 41*np.log(2)*np.power(2,-t)
quad(reward, 0, t)
但是,有时我会为t=13713.773637630298
获得一个下溢的FloatingPointError。如果我在交互式会话中执行此操作,我会看到以下内容(不会产生下溢错误):
# Sanity Checks
>>> quad(reward, 0, 0)
(0.0, 0.0)
>>> quad(reward, 0, np.inf)
(40.99999999999978, 1.2750366198868279e-07)
# Weird Stuff
>>> quad(reward, 0, 13000)
(41.00000000000001, 4.661522155502418e-07)
>>> quad(reward 0, 130000)
(3.511099523711482e-39, 6.981138006465757e-39)
我的问题是: