scipy quad uses only 1 subdivision and gives wrong result

不羁岁月 提交于 2019-12-02 02:23:29

Because the limits of integration are so far out in the tails of the Gaussian, you've fooled quad into thinking that the function is identically 0:

In [104]: f(-1000)
Out[104]: -0.0

In [105]: f(-500)
Out[105]: -0.0

In [106]: f(-80)
Out[106]: -0.0

In [107]: f(-50)
Out[107]: -6.2929842629835128e-141

You can fix this several ways, one of which is to add the argument points=[mu] to the call to quad:

In [110]: b = si.quad(f, -1001., 1001., full_output=True, points=[mu])
b
In [111]: b[0]
Out[111]: 1.0000000000000002
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!