Why does integrate.quad(lambda x: x*exp(-x**2/2)/sqrt(2*pi), 0.0, 100000) give 0?

我的梦境 提交于 2019-12-04 06:25:20

问题


This function is positive from 0 to inf, why give larger than 1000 will yield to 0, not reasonable.

import scipy.integrate as integrate
from math import *

integrate.quad(lambda x: x*exp(-x**2/2)/sqrt(2*pi), 0.0, 1000)
Out[52]: 
(0.3989422804014328, 1.6471510195390376e-11)
integrate.quad(lambda x: x*exp(-x**2/2)/sqrt(2*pi), 0.0, 100000)
Out[54]: 
(0.0, 0.0)

回答1:


For x larger than approx. 39, exp(-x**2/2) gives 0.0. When the upper limit of integration is 100000, the fraction of the interval of integration where the function is nonzero is so small that the quad algorithm never sees it. As far as quad is concerned, the function is identically 0.



来源:https://stackoverflow.com/questions/47193045/why-does-integrate-quadlambda-x-xexp-x2-2-sqrt2pi-0-0-100000-give-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!