Code covered by the BSD License  

Highlights from
Fast Kernel Density Estimator (Multivariate)

Be the first to rate this file! 46 Downloads (last 30 days) File Size: 32.3 KB File ID: #41187
image thumbnail

Fast Kernel Density Estimator (Multivariate)

by

 

09 Apr 2013 (Updated )

A very fast multivariate bandwidth calculation for KDE that can even be calculated from a GMM.

| Watch this File

File Information
Description

The code implements an approximation of the multivariate bandwidth calculation from [1]. In contrast to other multivariate bandwidth estimators, it can be estimated from a preclustered sample distribution offering a simple way of estimating compact and accurate KDEs with variable kernels.

The code provides a C source code for the engine of calculation and a routine to compile it automatically in Matlab.

The code includes three demos:
1. Multivariate KDE: demoBW_Estimation.m (it also compiles your code)
2. 1D KDE: demoBW_Estimation1D.m
3. Multivariate KDE with preclustering: demoBW_with_preclustering

 
Reasons to use the bandwidth estimator from [1]:
* Reasonably fast computation
* Handles multivariate bandwidths
* Can use weighted data
* Generally produces good estimates of the bandwidths
* Can be calculated from a Gaussian mixture model, not only directly from the samples
* Avoids numerical evaluations and iterative computation -- the bandwidth is analytically computed (even from a GMM) under some approximations.

Some advice:
If you're trying to estimate the KDE from "really" large datasets, then I suggest one of two things: (i) precluster the data first and apply [1]. (2) Use the online KDE, which learns the model by one data at a time -- the Matlab code for the oKDE is available from the author's homepage (http://www.vicos.si/People/Matejk).

[1] M. Kristan, A. Leonardis, D. Skočaj, "Multivariate online Kernel Density Estimation with Gaussian Kernels", Pattern Recognition, 2011.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
20 Jan 2014 Matej Kristan

@Aparna: The brute-force way is to discretize the pdf and find the maximum. The right way is to search by gradient ascent on the Gaussian Mixture Model. You can use the Mean Shift with the Gaussian kernel to do that. In fact, you can use my Matlab implementation that you can find as a part of the oKDE toolbox at my homepage (http://www.vicos.si/Research/Multivariate_Online_Kernel_Density_Estimation).

19 Jan 2014 Aparna

How can I find the max of the estimated pdf?

25 Oct 2013 Matej Kristan

Taylor. There is a demo function called "demoBW_with_preclustering.m" there you will find an example of how to contruct the pdf as well as how to visualize it. In short the line "kde = constructKDE(pdf.Mu, pdf.w, H, pdf.Cov) ; " is the line you're looking for in that function.

24 Oct 2013 J Taylor

What function returns the actual pdf? Obviously estimateBandwidth returns the bandwidths, but how do I obtain the estimated density function over some range for each dimension?

27 Sep 2013 Matej Kristan

Vinicius, the example is in the "demoBW_with_preclustering.m". On line 21 or so, there is an example of preclustering by calling "pdf = precluster( data ) ;".

27 Sep 2013 Vinicius Mourao Alves de Souz

I don't understand how I can input a pre-clustered data and obtain KDEs from these clusters. Can you give me an example? Thanks

Updates
10 Apr 2013

Some correction of the code for moment matching "momentMatchPdf.m" and additional example of very fast 1D KDE estimation "demoBW_Estimation1D.m".

11 Apr 2013

updated the "Description" field.

16 Apr 2013

added link to homepage

08 May 2013

Corrected plotting of a 1d distribution and some includes for properly installing the path to plotting tools.

Contact us