I'm trying to integrate a two-dimension KDE function with SciPy following this answer, but I'm getting an error that I provide more arguments than are required.
from scipy import integrate
import numpy as np
import scipy.stats as sts
# data
rvs = np.append(stats.norm.rvs(loc=0,scale=3,size=(2000,1)),
stats.norm.rvs(loc=1,scale=2,size=(2000,1)),
axis=1)
# fit kde
kde = stats.kde.gaussian_kde(rvs.T)
# failed attempts to calculate the integral:
print(integrate.nquad(kde, [[-1, 1],[-1, 1]])) # --> error: evaluate() takes 2 positional arguments but 3 were given
print(integrate.dblquad(kde, -1, 1, -1, 1)) # --> error: evaluate() takes 2 positional arguments but 3 were given
According to the documentation for Scipy.nquad, I must provide a func
object as the first argument. Is the KDE missing a required type? Can I extract the function that works for integration from the KDE object?