I am trying to integrate over the sum of two 'half' normal distributions. scipy.integrate.quad
works fine when I try to integrate over a small range but returns 0 when I do it for large ranges. Here's the code:
mu1 = 0
mu2 = 0
std1 = 1
std2 = 1
def integral_fun(x):
nor1 = 0.5 * ((1 / (np.sqrt(2 * np.pi) * std1)) * (np.e ** ((-(x-mu1) ** 2) / (2 * std1 **2))))
nor2 = 0.5 * ((1 / (np.sqrt(2 * np.pi) * std2)) * (np.e ** ((-(x-mu2) ** 2) / (2 * std2 **2))))
return nor1 + nor2
integrate.quad(integral_fun, -5, 5)
Out[54]: (0.9999994266968564, 8.668320228277793e-10)
integrate.quad(integral_fun, -10, 10)
Out[55]: (1.0000000000000002, 8.671029607900576e-10)
integrate.quad(integral_fun, -100000, 100000)
Out[56]: (0.0, 0.0)
Why is this happening?