将高斯与四边形集成时突然下降

Sudden drop when integrating a gaussian with quad

我正在尝试将 u -> exp(-u²/2) 从 -infinity 积分到 x。当我绘制函数时,在 21 左右突然下降,在 36 左右下降到 0,而它应该大致恒定为 2.5。你怎么解释?

import numpy as np
from scipy.integrate import quad
import matplotlib.pyplot as plt

def intExp(x):
    return quad(lambda u: np.math.exp(-u*u/2),-np.Inf, x, full_output=0)

def plot(a,b, u, v,s):
    plt.close()
    t = np.arange(a,b,s)
    plt.plot(t , map(intExp,t))
    plt.axis([a, b, u, v])
    plt.show()

plot(-10, 50, -1, 3, 1)

感谢您的帮助!

与步宽有关。将 epsabs 从其默认值更改为 1e-9 有效:

import numpy as np
from scipy.integrate import quad
import matplotlib.pyplot as plt

def intExp(x):
    return quad(lambda u: np.math.exp(-u*u/2),-np.Inf, x, full_output=0,epsabs=1e-9)

def plot(a,b, u, v,s):
    plt.close()
    t = np.arange(a,b,s)
    plt.plot(t , map(intExp,t))
    plt.axis([a, b, u, v])
    plt.show()


plot(-10, 50, -1, 3, 1)