powered by
Calculate the Gaussian kernel weights between rows of X1 and rows of X2.
X1
X2
kernel_weight(x1, x2, kernel = "gaussian", dist = "euclidean")
A distance matrix, with its (i, j)th element being the kernel weights for the i th row of X1 jth row of X2.
First data matrix
Second data matrix
The kernel function, currently only using Gaussian kernel.
The distance metric, currently only using the Euclidean distance.
# two matrices set.seed(1) x1 <- matrix(rnorm(10), 5, 2) x2 <- matrix(rnorm(6), 3, 2) kernel_weight(x1, x2)
Run the code above in your browser using DataLab