The environment is python 3.7.6, windows10.
The multiple integral integrate.nquad doesn't seem to work well and the result should be 1.000 (because it's a simultaneous probability density function), but it returns 1.326.
How can I get multiple integrals correctly?
code
import numpy as np
from scipy import integrate
def f_xy(x, y): if 0 <= y <= 1 and 0 <= x-y <= 1: return 4 * y * (x - y) else: return 0
integrate.nquad(f_xy, [[-np.inf, np.inf],[-np.inf, np.inf]])[0]
Out: 1.326
Recommended Posts