funs.kNNdist | R Documentation |
k
NN distancesTwo functions: kthNNdist
and kNNdist
.
kthNNdist
returns the distances between subjects and their k^{th} NNs. The output is an n \times 2 matrix where
n is the data size and first column is the subject index and second column contains the corresponding
distances to k^{th} NN subjects.
kNNdist
returns the distances between subjects and their k
NNs.
The output is an n \times (k+1) matrix where
n is the data size and first column is the subject index and the remaining k
columns contain the corresponding
distances to k
NN subjects.
kthNNdist(x, k, is.ipd = TRUE, ...) kNNdist(x, k, is.ipd = TRUE, ...)
x |
The IPD matrix (if |
k |
Integer specifying the number of NNs (of subjects). |
is.ipd |
A logical parameter (default= |
... |
are for further arguments, such as |
kthNNdist
returns an n \times 2 matrix where n is data size (i.e. number of subjects) and
first column is the subject index and second column is the k^{th} NN distances.
kNNdist
returns an n \times (k+1) matrix where n is data size (i.e. number of subjects) and
first column is the subject index and the remaining k
columns contain the corresponding
distances to k
NN subjects.
Elvan Ceyhan
NNdist
and NNdist2cl
#Examples for kthNNdist #3D data points, gives NAs when n<=k n<-20 #or try sample(1:20,1) Y<-matrix(runif(3*n),ncol=3) ipd<-ipd.mat(Y) kthNNdist(ipd,3) kthNNdist(Y,3,is.ipd = FALSE) kthNNdist(ipd,5) kthNNdist(Y,5,is.ipd = FALSE) kthNNdist(Y,3,is.ipd = FALSE,method="max") #1D data points X<-as.matrix(runif(5)) # need to be entered as a matrix with one column #(i.e., a column vector), hence X<-runif(5) would not work ipd<-ipd.mat(X) kthNNdist(ipd,3) #Examples for kNNdist #3D data points, gives NAs if n<=k for n,n+1,...,kNNs n<-20 #or try sample(1:20,1) Y<-matrix(runif(3*n),ncol=3) ipd<-ipd.mat(Y) kNNdist(ipd,3) kNNdist(ipd,5) kNNdist(Y,5,is.ipd = FALSE) kNNdist(Y,5,is.ipd = FALSE,method="max") kNNdist(ipd,1) kthNNdist(ipd,1) #1D data points X<-as.matrix(runif(5)) # need to be entered as a matrix with one column #(i.e., a column vector), hence X<-runif(5) would not work ipd<-ipd.mat(X) kNNdist(ipd,3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.