SciPy Quad 集成:准确度警告 [英] SciPy Quad Integration: Accuracy Warning
问题描述
我目前正在尝试使用 scipy.integrate.quad 计算积分,对于某些值,我收到以下错误:
I am currently trying to compute out an integral with scipy.integrate.quad, and for certain values I get the following error:
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/scipy/integrate/quadrature.py:616: AccuracyWarning: divmax (20) 超出.最新差值 = 2.005732e-02准确度警告)
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/scipy/integrate/quadrature.py:616: AccuracyWarning: divmax (20) exceeded. Latest difference = 2.005732e-02 AccuracyWarning)
查看文档,我并不完全清楚为什么会出现这个警告,它意味着什么,以及为什么它只出现在某些值上.
Looking at the documentation, it isn't entirely clear to me why this warning is raised, what it means, and why it only occurs for certain values.
推荐答案
在 scipy.integrate.quad
中有一个对差值函数的低级调用,它被迭代,它被迭代<代码>divmax 次.在您的情况下,divmax=20
的默认值.有一些函数可以覆盖此默认值——例如 scipy.integrate.quadrature.romberg
允许您将 divmax
(此处默认为 10)设置为关键字.当差值函数的容差不满足时,会抛出警告.将 divmax
设置为较高的值将运行更长时间,并有望满足容差要求.
in scipy.integrate.quad
there's a lower-level call to a difference function that is iterated over, and it's iterated over divmax
times. In your case, the default for divmax=20
. There are some functions that you can override this default -- for example scipy.integrate.quadrature.romberg
allows you to set divmax
(default here is 10) as a keyword. The warning is thrown when the tolerances aren't met for the difference function. Setting divmax
to a higher value will run longer, and hopefully meet the tolerance requirements.
这篇关于SciPy Quad 集成:准确度警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!