Multivariate kernel density estimation in Python
I am trying to use SciPy's gaussian_kde function to estimate the density of multivariate data. In my code below I sample a 3D multivariate normal and fit the kernel density but I'm not sure how to evaluate my fit. import numpy as np from scipy import stats mu = np.array([1, 10, 20]) sigma = np.matrix([[4, 10, 0], [10, 25, 0], [0, 0, 100]]) data = np.random.multivariate_normal(mu, sigma, 1000) values = data.T kernel = stats.gaussian_kde(values) I saw this but not sure how to extend it to 3D. Also not sure how do I even begin to evaluate the fitted density? How do I visualize this? There are