SciPy Quad Integration: Accuracy Warning

半腔热情 提交于 2019-12-11 03:11:51

问题


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) 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.


回答1:


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.



来源:https://stackoverflow.com/questions/24091411/scipy-quad-integration-accuracy-warning

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