File Exchange

image thumbnail

2D Bandwidth Estimator for KDE

version (25.3 KB) by Matej Kristan
2D kernel density estimator from weighted data.


Updated 08 Apr 2013

View License

The submission includes a code for estimating a 2D bandwidth ("getBandwidth.m") matrix for a Gaussian Kernel Density Estimator. The included demonstration code ("demoBWEstimation.m") estimates a bandwidth from a weighted set of data-points and displays the resulting KDE by tabulating it, as well as displaying it as a Gaussian Mixture Model. The bandwidth calculation is a special case of a more general bandwidth estimator [1], which was developed originally for online density estimation.

[1] Kristan et al., Multivariate Online Kernel Density Estimation with Gaussian Kernels, Pattern Recognition, 2011 (url:

Cite As

Matej Kristan (2020). 2D Bandwidth Estimator for KDE (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

bmv, thanks for the error dump. Apparently there was a leftover dependency on the Lightspeed Toolbox. I've updated the submission and it now includes the missing function.


>> demoBWEstimation

Undefined function 'col_sum' for input arguments of type 'double'.
Error in normmixpdf (line 56)
pl = logConstant - 0.5*col_sum(dx.*dx);
Error in evaluatePointsUnderPdf (line 17)
[ p, model ] = normmixpdf( model, X, minerr ) ;
Error in visualizePdf2d2 (line 51)
p = evaluatePointsUnderPdf(pdf, data) ;
Error in visualizeKDE (line 55)
outdat = visualizePdf2d2( kde.pdf, boundsIm, [], grans ) ;
Error in demoBWEstimation (line 47)
subplot(2,3,1) ; I_k = visualizeKDE('kde', kde_k, 'tabulated', 1) ;


added the following missing function:

function s = col_sum( a )

s = sum(a,1) ;

Just the description.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: Ensemble MCMC sampler