| Library: | xclust |
| See also: | distance mat2vec |
| Quantlet: | lpdist | |
| Description: | computes the so-called Lp-distances between the rows of a data matrix. In the case p=1 (absolute metric) or p=2 (euclidean metric) one should favour the function DISTANCE. |
| Usage: | d = lpdist(x, q, p) | |
| Input: | ||
| x | n x m matrix | |
| q | m x 1 matrix of non-negative weights of columns | |
| p | scalar parameter (p>0) of the Lp-metric | |
| Output: | ||
| d | n(n-1)/2 x 1 matrix of paired distances between the n row points (the sequence of distances is described in AGGLOM) | |
; load the library xclust
library ("xclust")
; generate some data
x = #(0, 0, 1, 1)~#(0, 1, 0, 1)
; column weights
q = #(1, 1)
; apply euclidean metric
lpdist (x, q, 2)
Content of object d [1,] 1 [2,] 1 [3,] 1.4142 [4,] 1.4142 [5,] 1 [6,] 1
| Library: | xclust |
| See also: | distance mat2vec |