drop enercast submodule; drop Rcpp requirement; fix doc, complete code, fix fix fix
[epclust.git] / epclust / tests / testthat / test-assignMedoids.R
CommitLineData
40f12a2f
BA
1context("assignMedoids")
2
3test_that("assignMedoids behave as expected",
4{
5 # Generate a gaussian mixture
282342ba
BA
6 n <- 999
7 L <- 7
8 medoids <- cbind( rep(0,L), rep(-5,L), rep(5,L) )
40f12a2f 9 # short series...
282342ba
BA
10 require("MASS", quietly=TRUE)
11 series <- t( rbind( MASS::mvrnorm(n/3, medoids[,1], diag(L)),
40f12a2f
BA
12 MASS::mvrnorm(n/3, medoids[,2], diag(L)),
13 MASS::mvrnorm(n/3, medoids[,3], diag(L)) ) )
14
15 # With high probability, medoids indices should resemble 1,1,1,...,2,2,2,...,3,3,3,...
282342ba
BA
16 mi <- assignMedoids(series, medoids)
17 mi_ref <- rep(1:3, each=n/3)
40f12a2f 18 expect_lt( mean(mi != mi_ref), 0.01 )
40f12a2f 19})