gausskernel {KRLS} | R Documentation |
Gaussian Kernel Distance Computation
Description
Given a N by D numeric data matrix, this function computes the N by N distance matrix with the pairwise distances between the rows of the data matrix as measured by a Gaussian Kernel.
Usage
gausskernel(X = NULL, sigma = NULL)
Arguments
X |
N by N numeric data matrix. |
sigma |
Positive scalar that specifies the bandwidth of the Gaussian kernel (see details). |
Details
Given two D dimensional vectors and
. The Gaussian kernel is defined as
where is the Euclidean distance given by
and is the bandwidth of the kernel.
Note that the Gaussian kernel is a measure of similarity between and
. It evalues to 1 if the
and
are identical, and approaches 0 as
and
move further apart.
The function relies on the dist
function in the stats package for an initial estimate of the euclidean distance.
Value
An N by N numeric distance matrix that contains the pairwise distances between the rows in X.
Author(s)
Jens Hainmueller (Stanford) and Chad Hazlett (MIT)
See Also
dist
function in the stats package.
Examples
X <- matrix(rnorm(6),ncol=2)
gausskernel(X=X,sigma=1)