nearest: Nearest neighbor computation for the TRUH statistic

Description Usage Arguments Value See Also Examples

View source: R/lib.R

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

1
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

1
2
3
4
5
6
7
8
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)

truh documentation built on Sept. 8, 2021, 9:08 a.m.