distancew0 {lazy.tools}R Documentation

Calculation of Weighted Distance Matrix

Description

Calculation of Weighted Distance Matrix

Usage

distancew0(X, W = diag(ncol(X)))

Arguments

X

n x r matrix

W

r x r diagonal maatrix

Details

This function calculates the weighted distance among the rows of X matrix by applying the a-th diagonal element of W matrix as the dimensional weights as:

d_ij =sqrt( sum_{a=1}^r w[a,a] (x[i,a]-x[j,a])^2 )

or

d_ij =sqrt( (x[i,]-x[j,])' W (x[i,]-x[j,]) )


Note that W matrix will NOT be squared when calculating distance.

Value

A matrices of size n x n

Examples

X <- matrix( c(0,0,  3,0,  0,4), 3,2,  byrow=1 )
distancew0( X )
W <- diag(c(2,1))
distancew0( X,W )


[Package lazy.tools version 0.1.6 ]