fixes: TODO, debug test.clustering.R and finish writing clustering.R
[epclust.git] / epclust / tests / testthat / helper.clustering.R
1 #shorthand: map 1->1, 2->2, 3->3, 4->1, ..., 149->2, 150->3, ... (is base==3)
2 I = function(i, base)
3 (i-1) %% base + 1
4
5 # NOTE: medoids can be a big.matrix
6 computeDistortion = function(series, medoids)
7 {
8 n = nrow(series) ; L = ncol(series)
9 distortion = 0.
10 if (bigmemory::is.big.matrix(medoids))
11 medoids = medoids[,]
12 for (i in seq_len(n))
13 distortion = distortion + min( colSums( sweep(medoids,1,series[,i],'-')^2 ) / L )
14 distortion / n
15 }