kde: Kernel Density Estimator over a Grid of Points

View source: R/kde.R

kdeR Documentation

Kernel Density Estimator over a Grid of Points

Description

Given a point cloud X (n points), the function kde computes the Kernel Density Estimator over a grid of points. The kernel is a Gaussian Kernel with smoothing parameter h. For each x \in R^d, the Kernel Density estimator is defined as

p_X (x) = \frac{1}{n (\sqrt{2 \pi} h )^d} \sum_{i=1}^n \exp \left( \frac{- \Vert x-X_i \Vert_2^2}{2h^2} \right).

Usage

kde(X, Grid, h, kertype = "Gaussian", weight = 1,
    printProgress = FALSE)

Arguments

X

an n by d matrix of coordinates of points used in the kernel density estimation process, where n is the number of points and d is the dimension.

Grid

an m by d matrix of coordinates, where m is the number of points in the grid.

h

number: the smoothing paramter of the Gaussian Kernel.

kertype

string: if kertype = "Gaussian", Gaussian kernel is used, and if kertype = "Epanechnikov", Epanechnikov kernel is used. Defaults to "Gaussian".

weight

either a number, or a vector of length n. If it is a number, then same weight is applied to each points of X. If it is a vector, weight represents weights of each points of X. The default value is 1.

printProgress

if TRUE, a progress bar is printed. The default value is FALSE.

Value

The function kde returns a vector of length m (the number of points in the grid) containing the value of the kernel density estimator for each point in the grid.

Author(s)

Jisu Kim and Fabrizio Lecci

References

Larry Wasserman (2004), "All of statistics: a concise course in statistical inference", Springer.

Brittany T. Fasy, Fabrizio Lecci, Alessandro Rinaldo, Larry Wasserman, Sivaraman Balakrishnan, and Aarti Singh. (2013), "Statistical Inference For Persistent Homology: Confidence Sets for Persistence Diagrams", (arXiv:1303.7117). To appear, Annals of Statistics.

See Also

kernelDist, distFct, dtm

Examples

## Generate Data from the unit circle
n <- 300
X <- circleUnif(n)

## Construct a grid of points over which we evaluate the function
by <- 0.065
Xseq <- seq(-1.6, 1.6, by=by)
Yseq <- seq(-1.7, 1.7, by=by)
Grid <- expand.grid(Xseq,Yseq)

## kernel density estimator
h <- 0.3
KDE <- kde(X, Grid, h)

TDA documentation built on May 29, 2024, 1:28 a.m.