distrectw {lazy.tools} | R Documentation |
Calculation of Weighted Distance Matrix between the rows of F and A
distrectw(F, A, Wa = matrix(1, nrow(A), ncol(A)))
F |
n x r matrix |
A |
p x r matrix |
Wa |
p x r maatrix |
This program calculated weighted distance between the rows of F matrix
and the rows of A matrix
by applying the j-th row as a set of dimensional weights.
d_ij = sqrt( (f[i,]-a[j,])' diag(Wa[j,]) (f[i,]-a[j,]) )
Note that Wa
matrix will NOT be squared when calculating distance.
A matrices of size n x p
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 )