为什么Integration.quad(lambda x:x * exp(-x ** 2/2)/sqrt(2 * pi),0.0,100000)给出0? [英] Why does integrate.quad(lambda x: x*exp(-x**2/2)/sqrt(2*pi), 0.0, 100000) give 0?

查看:211
本文介绍了为什么Integration.quad(lambda x:x * exp(-x ** 2/2)/sqrt(2 * pi),0.0,100000)给出0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此函数从0到inf为正,为什么给大于1000会产生0,这是不合理的.

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)

推荐答案

对于大于约x的x. 39,exp(-x**2/2)给出0.0.当积分上限为100000时,该函数为非零值的积分间隔的分数很小,以致quad算法永远看不到它.就quad而言,该函数等于0.

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.

这篇关于为什么Integration.quad(lambda x:x * exp(-x ** 2/2)/sqrt(2 * pi),0.0,100000)给出0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆