k <- runif(4, 4, 20)
prob <- c(0.2, 0.4, 0.3, 0.1)
mu <- matrix(rnorm(16), ncol = 4)
mu <- mu / sqrt( rowSums(mu^2) )
da <- rmixvmf(200, prob, mu, k)
nu <- sample(1:200, 180)
x <- da$x[nu, ]
ina <- da$id[nu]
xx <- da$x[-nu, ]
id <- da$id[-nu]
a1 <- dirknn(xx, ina, x, k = 5, mesos = TRUE)
a2 <- dirknn(xx, ina, x, k = 5, mesos = FALSE)
table(id, a1)
table(id, a2)
Run the code above in your browser using DataLab