| distrectw {lazy.tools} | R Documentation |
Calculation of Weighted Distance Matrix between the rows of F and A
Description
Calculation of Weighted Distance Matrix between the rows of F and A
Usage
distrectw(F, A, W = matrix(1, nrow(A), ncol(A)), R = NULL, outD2 = 0)
Arguments
F |
n x r matrix |
A |
p x r matrix |
W |
p x r maatrix |
R |
p x (r x r) array |
Details
This program calculates the weighted distance between the rows of F matrix
and the rows of A matrix as
d_{ij} = \sqrt( (f[i,]-a[j,])' diag(W[j,]) (f[i,]-a[j,]) )
d_{ij} = \sqrt( (f[i,]-a[j,])' R[,,j] (f[i,]-a[j,]) )
Note that W matrix will NOT be squared when calculating distance.
Value
A matrices of size n x p
Examples
F <- matrix( c(0,0, 3,0, 0,4), 3,2, byrow=1 )
A <- matrix( c(0,0, 3,4 ), 2,2, byrow=1 )
distrectw( F,A )
Wa <- matrix( c(1,1, 1,2 ), 2,2, byrow=1 )
distrectw( F,A, Wa )
R <- matrix(c(1,0, 0,1, 1,0.5, 0.5,3 ), ,2, byrow=TRUE)
# R <- t(R)
# dim(R)=c(2,2,2)
distrectw( F,A, R=R )
[Package lazy.tools version 1.0.0.20260516 ]