% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distance.R
\name{distancew}
\alias{distancew}
\title{Calculation of Weighted Distance Matrices}
\usage{
distancew(X, W = matrix(1, 1, ncol(X)), array = 1)
}
\arguments{
\item{X}{n x r matrix}

\item{W}{nG x r maatrix}

\item{array}{= 0 to make the result a list}
}
\value{
An array or a list of nG matrices of size n x n
}
\description{
Calculation of Weighted Distance Matrices
}
\details{
This function calculates the weighted distance among the rows of
\code{X} matrix  by applying the k-th row of \code{W} matrix
as a set of dimensional weights as:
\deqn{ d_{ijk} = \sqrt( \sum_{a=1}^r   w[k,a] (x[i,a]-x[j,a])^2 ) }
or
\deqn{ d_{ijk} = \sqrt( (x[i,]-x[j,])' diag(W[k,]) (x[i,]-x[j,]) ) }
\cr
Note that \code{W} matrix will NOT be squared when calculating distance.
\cr
}
\examples{
X <- matrix( c(0,0,  3,0,  0,4), 3,2,  byrow=1 )
distancew( X )
W <- matrix( c(2,1, 1,2, 1,1), 3,2, byrow=1 )
distancew( X, W )

}
