【发布时间】:2014-11-27 22:07:53
【问题描述】:
在集成普通 pdf 时,我从 scipy 集成.quad 函数中得到了一些奇怪的输出。这是我尝试使用的代码:
inpdf = lambda c: norm.pdf(50, loc=c, scale = 1)
result = integrate.quad(inpdf, -np.inf, np.inf)
print result
返回 (3.281718223506531e-99, 0.0) 这显然是错误的。 当我将 x 值更改为 0 时,在下面的 sn-p 中,我得到了适当的输出:
inpdf = lambda c: norm.pdf(0, loc=c, scale = 1)
result = integrate.quad(inpdf, -np.inf, np.inf)
print result
返回 (0.9999999999999998, 1.0178191320905743e-08) 非常接近 1,这是应该的。使用 R 的积分函数会发生完全相同的事情,所以也许这只是正交算法的一个已知属性?有谁知道为什么会这样?
【问题讨论】:
-
两个代码 sn-ps 是相同的 - 请编辑。
-
sum(stats.norm.pdf(50, loc=arange(0,100,0.01), scale = 1)) * 0.01-> 1
标签: python r numpy scipy numerical-integration