[go: up one dir, main page]

Skip to content
/ awkde Public
forked from mennthor/awkde

Adaptive Width KDE with Gaussian Kernels

License

Notifications You must be signed in to change notification settings

samsonq/awkde

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adaptive Width KDE with Gaussian Kernels

Installation

This uses the awesome pybind11 package which makes creating C++ bindings super convenient. Only the evaluation is written in a small C++ snippet to speed it up, the rest is a pure python implementation.

The setup is taken from the example at https://github.com/pybind/python_example Just clone the repository and invoke pip:

git clone https://github.com/mennthor/awkde
pip install [--user] [-e] ./awkde

Note: --user and -e are optional. Use --user to install in your user site-package directory (recommended) and -e if you want to only link the files to the site-package directories, so that when you make any changes in your local copy, you don't have to reinstall all the time.

Try to run the example/examply.py:

cd awkde/example
python example.py

You should get this plot in the examples folder (you need matplotlib for the plot):

example plot

Algorithm

The unweighted kernel density estimator is defined as

kernel density formula

where the product h * lambda takes the role of a local sigma.

The kernel bandwith is choosen locally to account for variations in the density of the data. Areas with large density gets smaller kernels and vice versa. This smoothes the tails and gets high resolution in high statistics regions. The local bandwidth paramter is defined as

kernel density formula

where

kernel density formula

is some normalization and ^f(X_i) the KDE estimate at the data point X_i. The local bandwidth is multiplied to the global bandwidth for each kernel.

Furthermore different scales in data is accounted for by scaling it via its covariance matrix to an equal spread. First a global kernel bandwidth is applied to the transformed data and then based on that density a local bandwidth parameter is applied.

All credit for the method goes to [1] and to S. Schoenen and L. Raedel for huge parts of the implementation. For information on Silverman or Scott rule, see [2] or [3].

References

  • [1] B. Wang and X. Wang, "Bandwidth Selection for Weighted Kernel Density Estimation", Sep. 2007, DOI: 10.1214/154957804100000000.
  • [2] D.W. Scott, "Multivariate Density Estimation: Theory, Practice, and Visualization", John Wiley & Sons, New York, Chicester, 1992.
  • [3] B.W. Silverman, "Density Estimation for Statistics and Data Analysis", Vol. 26, Monographs on Statistics and Applied Probability, Chapman and Hall, London, 1986.

About

Adaptive Width KDE with Gaussian Kernels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 88.1%
  • C++ 11.9%