Given two D dimensional vectors \(x_i\) and \(x_j\). The Gaussian kernel is defined as
$$k(x_i,x_j)=exp(\frac{-|| x_i - x_j ||^2}{\sigma^2})$$
where \(||x_i - x_j||\) is the Euclidean distance given by
$$||x_i - x_j||=((x_i1-x_j1)^2 + (x_i2-x_j2)^2 + ... + (x_iD-x_jD)^2)^.5$$
and \(\sigma^2\) is the bandwidth of the kernel.
Note that the Gaussian kernel is a measure of similarity between \(x_i\) and \(x_j\). It evalues to 1 if the \(x_i\) and \(x_j\) are identical, and approaches 0 as \(x_i\) and \(x_j\) move further apart.
The function relies on the dist
function in the stats package for an initial estimate of the euclidean distance.