k2d {mmpp} | R Documentation |
Convert Kernel Matrix to Distance Matrix
Description
k2d
provides various methods for converting kernel matrix to distance matrix and vice versa.
Usage
k2d(Mat, direction = "k2d", method = "norm", scale = 1, pos = TRUE)
Arguments
Mat |
matrix, either kernel matrix or distance matrix to be converted. |
direction |
a character string "k2d" or "d2k". The latter interpret the Mat as a distance matrix and convert it to a kernel matrix. Default "k2d". |
method |
a character string to specify how the matrix is converted. "Default "norm". |
scale |
a numeric parameter used to scale the matrix. Typically used in exp( - d(x,y)/scale). |
pos |
logical. If |
Details
There are various ways to convert kernel function values to distance between two points.
Normal-distance (when method="norm"
) means a conversion
d_ND(x,y) = sqrt k(x,x) - 2k(x,y) + k(y,y).
Cauchy-Schwarz-type conversion (method="CS"
) is more principled way:
d_CS(x,y) = arccos k^2(x,y)/k(x,x)k(y,y).
Other two simple ways are
d_exp(x,y) = exp(- k(x,y)/scale),
which is an exponential-type distance (method="exp"
), and
d_n(x,y) = 1 - k(x,y)/sqrt k(x,x)k(y,y),
which we call naive (method="naive"
).
For converting distance to kernel (direction="d2k"
), it should be noted that we usually have distance between pairs of points only, and distances from "origin" are unknown.
Double-centering (method="DC"
) is the most popular and simple way to convert distance to kernel. However, it does not make positive definite kernel in general,
and it sometimes require post-processing, e.g., cutting off negative eigenvalues (pos=TRUE
).
Another simple way is exponential map (method="exp"
), i.e., k(x,y) = exp( - d(x,y)/scale).
Author(s)
Hideitsu Hino hinohide@cs.tsukuba.ac.jp, Ken Takano, Yuki Yoshikawa, and Noboru Murata