Learn R Programming

GrammR (version 1.1.0)

MatrixkNorm: Calculate $l_p$-norm distance between samples

Description

Given a $N \times k$ matrix X, this function calculates the $l_p$ norm between rows.

Usage

MatrixkNorm(X, p)

Arguments

X
A $N \times k$ matrix
p
A positive integer value which determines the norm to be used. When $k = \infty$, the maximum norm is calculated.

Value

A $N \times N$ symmetric matrix, where $N$ is the number of rows of the argument matrix $X$. All the diagonal elements are zeroes and the $(i,j)^{th}$ element represents the $l_p$-norm distance between the $i^{th}$ and $j^{th}$ rows, given by $\left(\mathop{\sum}_{s=1}^{k} |X_{is} - X_{js}|^p \right)^{1/p}$

Examples

Run this code
    ## Not run: data(metagencounts)
#     Distance <- MatrixkNorm(metagencounts$Counts, p = 2);## End(Not run)

Run the code above in your browser using DataLab