0

I am using the scipy implementation of KDE to find the density estimation for 3-Dimensional data kde source. I was wondering how to get the bandwidth matrix for kde in scipy.kde . For 1D its just a scaler but for 3d it suppose to be a 3X3 matrix. but I dont know how to output the matrix. can anyone help thanks!

import numpy as np
from scipy import stats

data = np.array([[1, 4, 3], [2, .6, 1.2], [2, 1, 1.2],
         [2, 0.5, 1.4], [5, .5, 0], [0, 0, 0],
         [1, 4, 3], [5, .5, 0], [2, .5, 1.2]])
data = data.T 
kde = stats.gaussian_kde(data)
minima = data.T.min(axis=0)
maxima = data.T.max(axis=0)
space = [np.linspace(mini,maxi,20) for mini, maxi in zip(minima,maxima)]
grid = np.meshgrid(*space)
coords = np.vstack(map(np.ravel, grid))
#Evaluate the KD estimated pdf at each coordinate
density = kde(coords)
jquery404
  • 653
  • 1
  • 12
  • 26

1 Answers1

0

According to the documentation, kde.factor should give you the bandwidth. You should also re-read the methods kde.set_bandwidth and kde.covariance_factor - that might clarify things. If I recall kernel density estimation correctly, then the bandwidth should always be a float and not a matrix for higher dimensional data.

Daniel Lenz
  • 3,334
  • 17
  • 36
  • here it says in slider 5-7 [multivariate kde](http://www.mvstat.net/tduong/research/seminars/seminar-2005-03.pdf) H is a matrix.. am i missing anything. thanks – jquery404 Jul 07 '15 at 14:21