euclsq {rchemo} | R Documentation |
Matrix of distances
Description
—– Matrix (n, m
) of distances between row observations of two datasets X
(n, p
) and Y (m, p
)
- euclsq
: Squared Euclidean distance
- mahsq
: Squared Mahalanobis distance
—– Matrix (n, 1
) of distances between row observations of a dataset X
(n, p
) and a vector p
(n
)
- euclsq_mu
: Squared Euclidean distance
- mahsq_mu
: Squared Euclidean distance
Usage
euclsq(X, Y = NULL)
euclsq_mu(X, mu)
mahsq(X, Y = NULL, Uinv = NULL)
mahsq_mu(X, mu, Uinv = NULL)
Arguments
X |
X-data ( |
Y |
Data ( |
mu |
Vector ( |
Uinv |
For Mahalanobis distance. The inverse of a Choleski factorization matrix of the covariance matrix of |
Value
A distance matrix.
Examples
n <- 5 ; p <- 3
X <- matrix(rnorm(n * p), ncol = p)
euclsq(X)
as.matrix(stats::dist(X)^2)
euclsq(X, X)
Y <- X[c(1, 3), ]
euclsq(X, Y)
euclsq_mu(X, Y[2, ])
i <- 3
euclsq(X, X[i, , drop = FALSE])
euclsq_mu(X, X[i, ])
S <- cov(X) * (n - 1) / n
i <- 3
mahsq(X)[i, , drop = FALSE]
stats::mahalanobis(X, X[i, ], S)
mahsq(X)
Y <- X[c(1, 3), ]
mahsq(X, Y)
[Package rchemo version 0.1-2 Index]