nearest {truh}R Documentation

Nearest neighbor computation for the TRUH statistic

Description

For a given d dimensional vector \mathbf{y}, this function finds the nearest neighbor of \mathbf{y} in a n\times d matrix \mathbf{U}.

Usage

nearest(y, U, n, d)

Arguments

y

a d dimensional vector.

U

a n\times d matrix where n represents the sample size and d is the dimension of each sample.

n

the sample size.

d

dimension of each sample.

Value

  1. d1 - nearest neighbor of \mathbf{y} in \mathbf{U}

  2. d2 - nearest neighbor of d1 in \mathbf{U}

See Also

truh

Examples

library(truh)
n = 100
d = 3
set.seed(1)
y = rnorm(3)
set.seed(2)
U = matrix(rnorm(n*d),nrow=n,ncol=d)
out = nearest(y,U,n,d)


[Package truh version 1.0.0 Index]